I placed it in starterplayerscripts in localscript, but it still dont work I tried to put it in serverscriptservice but it still don't work Pls help!
local Players = game:GetService("Players") local plr = Players.LocalPlayer
local PlayerMoneyValue = plr.leaderstats.Reality
while true do wait(0.5)
if PlayerMoneyValue.Value >= 0 then
local char = plr.Character
if not char then continue end
char.Humanoid:Takedamage(10)
end
end
I would recommend checking from the server to prevent exploiters and you should probably make sure the leaderstats are loaded by using waitforchild instead of just going straight to plr.leaderstats.Reality
local Players = game:GetService("Players") game.Players.PlayerAdded:Connect(function(player) local PlayerMoneyValue = player:WaitForChild'leaderstats':WaitForChild'Reality' player.CharacterAdded:Connect(function(character) local Humanoid = character:WaitForChild'Humanoid' while true do task.wait(.05) if PlayerMoneyValue.Value >= 0 then Humanoid:TakeDamage(10) end if Humanoid.Health <= 0 then break end end end) end)