Basically, I have a leaderstat that is named “Money” and I have it because Im making a simulator type of game that doors open on a leaderstat value.
Im testing to see if the door isnt opening due to the value, and it was. I had my value as 2, and it was prinint 0.
Ive tried looking on different forums and videos but Im unable to find anything. Ive also made it so the value updates on the server side instead of the client side but it still didnt work.
This is a local script in starter gui. Its a local script because if it was a server side script everyone would have access to other player world purchases.
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Money = instance.new("IntValue")
Money.Name = "Money"
Money.Parent = leaderstats
--Have a script so when the player activates a proximity prompt it will give them 1 leaderstat value
print(Money.Value)
end)
first off I’d recommend that you dont change the value via the client, as by doing that, it becomes incredibly exploitable.
Do you have multiple print statements? Or do you just print the value on that line?
The problem is that that print statement only prints once, so any changes you make wont be printed. You’ll need to print the value after you’ve changed it.
you can tell when a proximity prompt is triggered on the server the same way you can tell when its triggered on the client, except its a little different, as on the server you dont have the player, but the triggered function provides the player like so:
local Prompt = YourPromptHere
Prompt.Triggered:Connect(function(Player)
local MoneyValue = Player.leaderstats.Money
MoneyValue.Value += 1
end)
Instead of using a wait delay, to tell when it changes you can use the :GetPropertyChangedSignal event to tell when it changes, example with your current code:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Money = instance.new("IntValue")
Money.Name = "Money"
Money.Parent = leaderstats
Money:GetPropertyChangedSignal('Value'):Connect(function()
print(Money.Value)
end)
end)