Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how can i fix the script so when i have 100 money a brick changes colour?

it a local script only 1 people can see i think so that fine yes my grammer is bad becousi i no yes ingliss

while true do
local plr = game.Player.LocalPlayer
if plr.WaitForChild("leaderstats").Money.Value = 100 then
workspace.ButtonModel.Color = Color.new("Pastel Blue")
end
end

2 comments

1

You have a few mistake, I’ll see what I can do.

1

ok ty

2 answers

✓ Accepted answer

Hello, ProbablyRiley.

I see a few errors.

Explanation after the script


while true do
local plr = game.Player.LocalPlayer
if plr.WaitForChild("leaderstats”).Money.Value = 100 then
workspace.ButtonModel.BrickColor == BrickColor.new("Pastel Blue")
end
end

at line 3 you forgot ==, and in line 4 you forgot brick color but did color instead

10 comments

1

ill try it thaks

1

doesnt work

0

What’s the output?

1

money isnt a valid member of leaderstats

0

You have a value of the currency, right?

1

yes its name is money

1

then it should work, are you sure?

1

oh wait the other script for leaderstats is disabled

1

now it works tysm

0

have a good day

Optimized version, since you don't need a loop.


-- Index static variables outside of function
local localPlayer = game.Players.LocalPlayer
local leaderstats = localPlayer:WaitForChild('leaderstats')
local ButtonModel = workspace:WaitForChild("ButtonModel")

-- Anyonymous function checks for Value changing
leaderstats:GetPropertyChangedSignal("Value"):Connect(function()
	-- == compares, = sets
	if leaderstats.Value == 100 then
		-- BrickColor, not Color. 
		ButtonModel.BrickColor == BrickColor.new("Pastel Blue")
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.