Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Changing Body Colors Via GUI?

Asked by 9 years ago

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)

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

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.

0
cheers skunk940 10 — 9y
Ad

Answer this question