Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does it stop working after player resets?

local player = game.Players.LocalPlayer or script.Parent.Parent.Parent.Parent.Parent.Parent
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.TargetFolder.Target.Value then
				Gget[i].BrickColor = BrickColor.new(script.Parent.Name)
				end
			end
		end
	end
end)


1 answer

✓ Accepted answer

You never get the new character
Where are we? Limbo, I think.

Stick this at the end of your code to make sure that your character is always up to date.

player.CharacterAdded:connect(function(c)
	character = c
end);

This discussion is preserved as it was. New answers, comments, and votes are closed.