My local script isn't recognizing my leaderstats value? My script is:
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)
Thanks!
The script is wrong. You are using a when a player joins, since the server executes the server scripts first, leaderstats may or not been made. Solution:
--\\Client local player = game:GetService("Player").LocalPlayer --\\Services local rs = game:GetService("ReplicatedStorage") local gsg = game:GetService("StarterGui") if player.leaderstats.Purchases.Value == 1 then print("Hi") gsg.ScreenGui.Frame1.Desert.Visible = true else gsg.ScreenGui.Frame1.Desert.Visible = false end end)
Hello! Hope I'm here to answer your question. Your script is incorrect because game.Players.PlayerAdded is a server sided event The correct script would be
if game.Players.LocalPlayer:WaitForChild("leaderstats").Purchases.Value == 1 then print("Hi") game.StarterGui.ScreenGui.Frame1.Desert.Visible = true else game.StarterGui.ScreenGui.Frame1.Desert.Visible = false end
Wait before you check :)