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 suspected LocalPlayer but am unsure how to use getPlayerfromCharacter in a GUI button rather than a OnTouch button. Relatively unsused to using this syntax.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
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

2 comments
Try re-assigning 'character' every time he respawns (using the CharacterAdded event)
What would be a better way of doing this?