Help with Leaderstat script

I am trying to make a GUI that appears when the player gets a leaderstat value of 100. It doesn’t work and I’m not sure why. could I please have some help?

Script


LevelNeeded = 100


game.Players.PlayerAdded:connect(function(p)
	local stats = Instance.new("IntValue", p)
	stats.Name = "leaderstats"
	local money = Instance.new("IntValue", stats)
	money.Name = "Money"

	
	local PlayerGui = p:WaitForChild("PlayerGui")
	if money.Value >= LevelNeeded then
		PlayerGui.Menu.Enabled = true
		
	end
end)

Thank you for your help 
2 Likes

the first object(leaderstats) must be a folder. Try this…

If that doesn;t work, it could be that the player added event is to slow. Try testing in real game instead of in studio.

2 Likes

Try connecting a GetPropertyChangedSignal event to your Money value.

LevelNeeded = 100


game.Players.PlayerAdded:connect(function(p)
	local stats = Instance.new("IntValue", p)
	stats.Name = "leaderstats"
	local money = Instance.new("IntValue", stats)
	money.Name = "Money"

	
	local PlayerGui = p:WaitForChild("PlayerGui")

    money:GetPropertyChangedSignal("Value"):Connect(function()
	  if money.Value >= LevelNeeded then
		  PlayerGui.Menu.Enabled = true
	  end
    end
end)
2 Likes

Thank you for the help i will test those scripts in a bit

Im actually pretty sure you’re not able to modify UI’s on the server… Try using a remote event to tell the client when to open the UI

1 Like

You are able to modify UI’s on the server but it can be sometimes bit wonky.

1 Like

I really need help with my leaderStats.

PROBLEM - I’m trying to make a zombie game and I’m trying to figure out how to make it where every time you kill a zombie it will show you how many you and your team killed but none of my scripts will work.

@flkfv

I really need help with my leaderStats.

PROBLEM - I’m trying to make a zombie game and I’m trying to figure out how to make it where every time you kill a zombie it will show you how many you and your team killed but none of my scripts will work.

I think it would be easier for you to make a new topic or Message Flkfv to get an answer.