My leaderstats value isn't being recognised by a local script. I have had many attempts with this script but none have worked, here is my local script: game.Players.PlayerAdded:connect(function()
if game.Players.LocalPlayer.leaderstats.Purchases.Value == 1 then print("Hi") game.StarterGui.ScreenGui.Frame1.Desert.Visible = true else game.StarterGui.ScreenGui.Frame1.Desert.Visible = false end end)
This is what it looks like: https://ibb.co/0MmHShY and this is what it's supposed to look like: https://ibb.co/NYRpngM Thanks if anyone can help!
Make sure you put this in a local script (inside the desert button)
local purchases = game.Players.LocalPlayer.leaderstats.Purchases purchases.Changed:Connect(function() if purchases.Value == 1 then print("Hi") script.Parent.Visible = true else print("Bye") script.Parent.Visible = false end end)
when the script runs it checks instantly and since it's 0 at the beginning it makes the visible false and ignores any changes after that (unless you manually write that down as I did above)
It may not be problem in recognation, this script would run once to check if that value is true or false. You should wrap that if statement in signal changed event or while true loop:
Instance:GetPropertyChangedSignal("Value"):Connect(function() Or While true do wait(what you want) end
I'm sorry I don't really understand, where would I put my script in this script and how should I tell it what leaderstat? Thanks!
Instance:GetPropertyChangedSignal("Value"):Connect(function() Or While true do wait(1) end