Why would I need to put a wait(1) here for this script to work when you press a button? I'd appreciate if anyone could explain to me why I must put a wait(1)
wait(1) local Player = game.Players.LocalPlayer local Character = Player.Character local Button = script.Parent local BodyColors = Character:FindFirstChild("Body Colors") Button.MouseButton1Click:Connect(function() BodyColors.HeadColor3 = Color3.new(1, 232/255, 220/255) BodyColors.LeftArmColor3 = Color3.new(1, 232/255, 220/255) BodyColors.LeftLegColor3 = Color3.new(1, 232/255, 220/255) BodyColors.RightArmColor3 = Color3.new(1, 232/255, 220/255) BodyColors.RightLegColor3 = Color3.new(1, 232/255, 220/255) BodyColors.TorsoColor3 = Color3.new(1, 232/255, 220/255) end)
You actually don't need a wait there at all. The likely error is you're calling Player.Character too early as they may not even have been loaded in all the way. Best advice is this.
local Player = game:GetService("Players").LocalPlayer local Character = Player.Character or Player.CharacterAdded repeat wait() until Character local Button = script.Parent local BodyColors = Character:FindFirstChild("Body Colors") Button.MouseButton1Click:Connect(function() BodyColors.HeadColor3 = Color3.new(1, 232/255, 220/255) BodyColors.LeftArmColor3 = Color3.new(1, 232/255, 220/255) BodyColors.LeftLegColor3 = Color3.new(1, 232/255, 220/255) BodyColors.RightArmColor3 = Color3.new(1, 232/255, 220/255) BodyColors.RightLegColor3 = Color3.new(1, 232/255, 220/255) BodyColors.TorsoColor3 = Color3.new(1, 232/255, 220/255) end)
Hope this helps :)