-- NinjoOnline -- local sword2level = 5 local sword3level = 10 local sword4level = 20 print("0") while wait() do for _, player in pairs(game.Players:GetPlayers()) do if player then print("1") local shop = player:WaitForChild("Shop") if shop then print("2") local stats = player:WaitForChild("leaderstats") if stats then print("3") local level = stats:WaitForChild("Level") if level then print("4") level.Changed:connect(function(playerLevel) print("5") if playerLevel >= sword2level then print("6") shop:WaitForChild("KnightsSword").Value = true elseif playerLevel >= sword3level then shop:WaitForChild("ShadowDancer").Value = true elseif playerLevel >= sword4level then shop:WaitForChild("OrcBlade").Value = true end end) end end end end end end
The script is located inside serverscriptstorage and is a serverscript. It prints 0, but thats it. Please help.
Your script should be put into serverscriptservice, not serverstorage. You shouldn't be using :WaitForChild() if you are checking to see if an item exists. :WaitForChild() will wait forever until that item exists, even if it will never exist. If you are checking to see if an item exists, then use :FindFirstChild(), if you know an item will eventually exist and hasn't been created/loaded yet, then use :WaitForChild(), otherwise your script will wait forever.
This should fix your problems.
local sword2level = 5 local sword3level = 10 local sword4level = 20 local players = game:GetService'Players' -- If the player service doesn't already exist print("0") while wait() do repeat wait() until players.NumPlayers >= 1 -- Wait until there is 1 or more players in the game for _, player in pairs(players:GetPlayers()) do print("1") local shop = player:FindFirstChild("Shop") if shop then print("2") local stats = player:FindFirstChild("leaderstats") if stats then print("3") local level = stats:FindFirstChild("Level") if level then print("4") level.Changed:connect(function(playerLevel) print("5") if playerLevel >= sword2level then print("6") shop:WaitForChild("KnightsSword").Value = true elseif playerLevel >= sword3level then shop:WaitForChild("ShadowDancer").Value = true elseif playerLevel >= sword4level then shop:WaitForChild("OrcBlade").Value = true end end) end end end end end