In my game a function allows users to morph into a model then colour those model parts using this script. It works fine in testing mode and in Online mode, but once players reset the coloring script stops working altogether.
I think it may be the character added function but I don't know how to force it to refresh even after the player resets. Any suggestions?
local player = game.Players.LocalPlayer local character = player.CharacterAdded:wait() repeat wait() until repeat wait() until player.CharacterAdded:connect(function() loaded = true end) script.Parent.MouseButton1Click:connect(function() local Get = character:GetChildren() for i = 1, #Get do if Get[i].ClassName == "Model" then local Gget = Get[i]:GetChildren() for i = 1, #Gget do if Gget[i].Name == script.Parent.Parent.Parent.Parent.Target.Value then Gget[i].BrickColor = BrickColor.new(script.Parent.Name) end end end end end)
Thankyou very much
The problem is that character
becomes nil
after the player dies, and remains like that even after respawning. To fix this, you could change line 3 to this:
repeat wait() until repeat wait() until player.CharacterAdded:connect(function(char) character = char loaded = true end)