I am trying to create a gui shop that changes the players body color, via BodyColors (A body colors part) in the person. When the shop button is pressed however nothing happens. Any ideas?
wait(0.5) player = script.Parent.Parent.Parent.Parent.Parent money = player.leaderstats.Wins price = 0 function buy() if money.Value >= price then player.CharacterAdded:wait() player.Character.BodyColors.TorsoColor = BrickColor.new(104) end end script.Parent.MouseButton1Down:connect(buy)
You are waiting for a new character to spawn!
That isn't necessary since the GUI is already loaded. To be safe, you can check that it exists, but you don't need to wait for anything:
if player.Character and player.Character:FindFirstChild("BodyColors") then -- The above should replace the wait on line 9 of the snippet you posted
Alternatively, you can almost surely safely remove line 9 altogether and not add any extra checks like this one.