Wolf_EX Posted June 3, 2018 Share Posted June 3, 2018 I made an item that changes the character while equipped, but i can't figure out how to change it back to the original character. On the OnEquip function I use "owner.AnimState:SetBuild" which works fine, but I don't know what to add to the OnUnequip function to change it back to the original build. If I could get the name of the character, I could set the build back to that, but I couldn't find any code that does that. Closest I found was printing "ThePlayer" show and id and name of your character but couldn't figure out how to get just the character name. Link to comment Share on other sites More sharing options...
Wolf_EX Posted June 5, 2018 Author Share Posted June 5, 2018 I found a solution. If anyone is interested I used the HasTag function to find out which character the player is. Link to comment Share on other sites More sharing options...
IronHunter Posted June 5, 2018 Share Posted June 5, 2018 owner.prefab returns the prefab which is also the build for stock characters. Link to comment Share on other sites More sharing options...
Wolf_EX Posted June 5, 2018 Author Share Posted June 5, 2018 Thanks! this makes my code look so much cleaner. I have one more question. If I load a game while the item is equipped, it shows the character image instead of the new one. I tried to fix it with an OnLoad function but having an issue local function onload(inst, owner) print("loaded") if inst.components.equippable:IsEquipped() then owner.AnimState:SetBuild("wilton") end end The onload function is getting called since it's printing "loaded" to the console but the "if inst.components.equippable:IsEquipped()" isn't returning true. Maybe it's not considered equipped until after the onload function is called? 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