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

For some reason my if then isn't working with a value?

Hello! I was wondering why this script wasn't working. It is in StarterGui in a local script

while true do
	if game.players.LocalPlayer.stats.Green.value = 1 then
		workspace.toto.TowerPortal.towername.BrickColor = BrickColor.new ("Sea green")
	end
end

3 answers

✓ Accepted answer

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

local player = game.Players.LocalPlayer

while true do
	for _,object in pairs(player.leaderstats:GetChildren()) do
		wait()
	if object.Value == 1 then
		workspace.toto.TowerPortal.towername.BrickColor = BrickColor.new("Sea green")
		end	
	end
end

leaderstats script (If you already have one don't write this)

game.Players.PlayerAdded:connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local Green = Instance.new("IntValue") 
	Green.Name = "Green" 
	Green.Parent = leaderstats

end)


This is probably really inefficient because im using some old methods but it works anyway :/

8 comments

0

Thanks! I'll try that!

0

I tried and it says Players.Stoutscientist.PlayerGui.LocalScript:1: Incomplete statement: expected assignment or a function call

0

Also I made sure stats is in the local player so it isn't that

0

Try adding a wait().

0

ok i'm trying to see what I did wrong

0

I re did mine but its probably bad and outdated but it still works!

0

THANK YOU SO MUCH IT WORKED

0

np

Howdy!

When writing statements, you use two equal signs. In other times, use just one. Try what I have below.

while true do
    if game.players.LocalPlayer.stats.Green.value == 1 then
        workspace.toto.TowerPortal.towername.BrickColor = BrickColor.new ("Sea green")
    end
end

##If this helped you out, consider accepting this answer for those sweet, sweet reputation points. If not, comment below and I (or someone else) will help you out.

##Be sure to check out the Roblox API Documentation as well for additional reference.

On top of the past answers, .Value and .Players need to be capitalized in "game.players.LocalPlayer.stats.Green.value"

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