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

Script not detecting leaderstat value?

My script isn't detecting a leaderstat value? Here is the script:

Sever Script

local purchases = game.Players.LocalPlayer.leaderstats.Purchases.Value

game.Players.PlayerAdded:connect(function(Player)
	if Player.leaderstats.Purchases == 1 then
		game.StarterGui.ScreenGui.Frame1.Desert.Visible = true
	else
		game.StarterGui.ScreenGui.Frame1.Desert.Visible = false
end
end)


Does anyone know how to fix this?

3 answers

You can't find game.Players.LocalPlayer in a script, this needs to be done in a localscript

2 comments

0

oh right, I guess I must not have seen that lol

0

It still didn't work:

it didn't work

game.Players.PlayerAdded:connect(function(Player) if Player.leaderstats.Purchases.Value == 1 then game.StarterGui.ScreenGui.Frame1.Desert.Visible = true else game.StarterGui.ScreenGui.Frame1.Desert.Visible = false end end)

Here dude, try this:

game.Players.PlayerAdded:connect(function(Player)
    if Player.leaderstats.Purchases.Value == 1 then
        game.Players[Player].PlayerGui.ScreenGui"Frame1".Desert.Visible = true
    else
        game.Players[Player].PlayerGui.ScreenGui"Frame1".Desert.Visible = false
end
end)

2 comments

0

do I do this local script or server script?

0

that doesn't work either, this is what it looks like: https://ibb.co/0MmHShY and this is what it should look like: https://ibb.co/NYRpngM Thanks anyways!

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