Problem with color button

Its giving me an error that says unable to cast int to int please help,

local button = script.Parent

button.MouseButton1Click:Connect(function()
	local player = game.Players.LocalPlayer
	local character = player.Character
	if character and character:FindFirstChild("Torso") then
		character.Torso.BrickColor = BrickColor.new(button.BackgroundColor.Color)
	end
end)
1 Like
character.Torso.Color = button.BackgroundColor3

12:31:21.736 Players.treeisnotcool.PlayerGui.colorGamepass.colorFrame.ScrollingFrame.white.Script:5: attempt to index nil with 'Character' - Server - Script:5 gave me this error

fixed it :smiley:

 local button = script.Parent

button.MouseButton1Click:Connect(function()
	local player = button.Parent.Parent.Parent.Parent.Parent
	local character = player.Character
	if character and character:FindFirstChild("Torso") then
		character.Torso.BrickColor = BrickColor.new(button.BackgroundColor.Color)
	end
end)

yeah because if you put that as a Server-Script then LocalPlayer doesn’t exist.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.