Hello! I was wondering why this script wasn't working. It is in StarterGui in a local script
1 | while true do |
2 | if game.players.LocalPlayer.stats.Green.value = 1 then |
3 | workspace.toto.TowerPortal.towername.BrickColor = BrickColor.new ( "Sea green" ) |
4 | end |
5 | end |
It's not working because you are setting a value with one equals sign. Using 2 equals signs waits for a value, so to fix you would do
UPDATED:
This is in a local script inside of the starter gui
01 | local player = game.Players.LocalPlayer |
02 |
03 | while true do |
04 | for _,object in pairs (player.leaderstats:GetChildren()) do |
05 | wait() |
06 | if object.Value = = 1 then |
07 | workspace.toto.TowerPortal.towername.BrickColor = BrickColor.new( "Sea green" ) |
08 | end |
09 | end |
10 | end |
leaderstats script (If you already have one don't write this)
01 | game.Players.PlayerAdded:connect( function (player) |
02 | local leaderstats = Instance.new( "Folder" ) |
03 | leaderstats.Name = "leaderstats" |
04 | leaderstats.Parent = player |
05 |
06 | local Green = Instance.new( "IntValue" ) |
07 | Green.Name = "Green" |
08 | Green.Parent = leaderstats |
09 |
10 | end ) |
This is probably really inefficient because im using some old methods but it works anyway :/
Howdy!
When writing statements, you use two equal signs. In other times, use just one. Try what I have below.
1 | while true do |
2 | if game.players.LocalPlayer.stats.Green.value = = 1 then |
3 | workspace.toto.TowerPortal.towername.BrickColor = BrickColor.new ( "Sea green" ) |
4 | end |
5 | end |
On top of the past answers, .Value and .Players need to be capitalized in "game.players.LocalPlayer.stats.Green.value"