Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My emotes gui work at first but after I reset my character it don't work anymore, how to fix it ?

Asked by 5 years ago

Hi I've made a emote gui which it's very working but after I reset my character the emotes doesn't work anymore and it pops up this error and I haven't figure out how to fix it yet : " Loadanimation requires the humanoid object (player1.Humanoid) to be a descendant of the game object "

Here's my script

01wait(1)
02local user = game.Players.LocalPlayer
03repeat
04    wait()
05until user.Character
06local Input = game:GetService("UserInputService")
07local animen = script.Parent.Parent.Parent:WaitForChild("Dances")
08local speeder, speedval = animen:WaitForChild("Speeddancehaha"), 1
09local mouse = user:GetMouse()
10local scrollingframe = script.Parent
11local anim
12local char = user.Character
13local humanoid = char:WaitForChild("Humanoid")
14local ftime = 0.7
15function playanim(id, lola)
View all 67 lines...

Please help me fix this annoying errors

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

It's because you're not re-referencing the character's humanoid. Every time a character dies it destroys that old character and creates a new one, therefore, any references to character or humanoid are nil. You can fix the character like this

1local char = player.Character or player.CharacterAdded:Wait() -- This essentially runs and sais if the character then char == character if not then it waits till its added and then it's then the character

The humanoid you could just re-reference every time you call the playanim function like so

1function playAnim()
2    local humanoid = char.Humanoid or char:WaitForChild("Humanoid") -- This either gets the valid humanoid or waits for a valid humanoid
3end

If this answers your question please mark it as answered or an upvote. Good luck!

  • Best Regards, - Syn
0
Still not working :( II_Minecraftsteves 15 — 5y
0
Add some prints and see where it's not working johndeer2233 439 — 5y
0
Oh my bad i forgot it's at line 46 - global playanim II_Minecraftsteves 15 — 5y
0
Ye but thats a whole function with 40 lines it's not the actual problem johndeer2233 439 — 5y
View all comments (3 more)
0
It's telling you thats theres an error in that function, add prints to find it johndeer2233 439 — 5y
0
i couldn't find it, sorry :( II_Minecraftsteves 15 — 5y
0
I would love to help you but without pinpointing the error I don't know where to start johndeer2233 439 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Try doing LocalScript and doing FireServer, but don't put LocalScript in the gui that doesn't restart when restarting

Answer this question