function ded(hahadedgobrrr) game.Players.LocalPlayer.leaderstats.XP.Value = game.Players.LocalPlayer.leaderstats.XP.Value + 25 end script.Parent.Humanoid.Died:Connect(ded)
Code above
Im trying to make an rpg but this no work!
local xp_stat = game:GetService("Players").LocalPlayer:WaitForChild("leaderstats"):WaitForChild("XP") local humanoid = script.Parent:FindFirstChildOfClass("Humanoid") or script.Parent:WaitForChild("Humanoid") coroutine.wrap(function() humanoid.Died:Wait() xp_stat.Value += 1 end)()
might have grammar errors, i wrote this from the comments
You cannot add stats from a local script. This allows exploiters to instantly give themselves inf exp.
-- make sure this is in a server script game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local humanid = character:WaitForChild'Humanoid' humanoid.Died:Connect(function() player.leaderstats.XP.Value += 25 end end) end)