I made a Custom Character (Placing a StarterCharacter and StarterHumaniod in StarterPlayer) and I'm trying to have it so when a player clicks on a button their torso will change to the color they choose. (If they choose the red button their torso will turn red) They can only do this if they have enough coins though.
local player = game.Players.LocalPlayer
local leaderboard = player:WaitForChild("leaderstats")
local button = script.Parent
local price = button:WaitForChild("Price")
local color = button:WaitForChild("ColorName")
button.MouseButton1Click:Connect(function()
if leaderboard.Coins.Value >= price.Value then
game.Workspace.player.Torso.BrickColor = BrickColor.new("Purple")
script.Parent.MouseButton1Down:connect(clicked)
end
end
A quick overview of my script: the second line accesses the leaderboard and stats (where the players coins are). The third fourth and fifth lines access the button and the values that are next to the button. What it is supposed to do is when the button is clicked the script sees if the player has enough coins and than goes into the player and changes the Torso to a certain color. (The player is not supposed to lose coins when they purchase because I am changing the stats to levels at some point) I don't know why it isn't changing the Torso color of the player. If anyone can help that would be great!

2 comments
Can I add you on team create so you can help me? Because for some reason it is not working and I'm probably just messing it up.
@tawk1215 sure