reims9875 Posted June 15, 2021 Share Posted June 15, 2021 How to prevent my character from wearing some hats. My character has horns when he puts on his hat horns are cut off. Link to comment Share on other sites More sharing options...
Goregonzola Posted June 17, 2021 Share Posted June 17, 2021 (edited) Hey there! This coding makes your character to refuse to wear any type of headgear: Spoiler local _Equip = inst.components.inventory.Equip inst.components.inventory.Equip = function(self, item, old_to_active) if not item or not item.components.equippable or not item:IsValid() then return end if item.components.equippable.equipslot == EQUIPSLOTS.HEAD then self:DropItem(item) self:GiveItem(item) if inst and inst.components.talker then inst.components.talker:Say("My horns are in the way!") end return end return _Equip(self, item, old_to_active) end You have to put this into your character's prefab file, inside local master_postinit = function(inst) You can replace the purple line with any other announce line. If you don't want your character to say anything when they decline a hat, just delete the green and the purple lines. If you want your character to only refuse specific hats, replace the orange line with this one: Spoiler if item.prefab == "eyebrellahat" or item.prefab == "footballhat" then This example makes the character to refuse the Eyebrella and the Football Helmet, but you can replace these with any other hat. Let me know if I've messed up something, but I think it's foolproof. Cheerio! Edited June 17, 2021 by C_Thun 1 1 Link to comment Share on other sites More sharing options...
reims9875 Posted June 18, 2021 Author Share Posted June 18, 2021 Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now