Im making a game where if the player dies their checkpoint are reset i got the Datastore working along with the checkpoint system but im having issues here not knowing how to write such script here is where i left off please help me!
local RPS = game:GetService(“ReplicatedStorage”)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild(“Humanoid”)
local DeathEvent = RPS.Events.DeathEvent
local RPS = game:GetService(“ReplicatedStorage”)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild(“Humanoid”)
local DeathEvent = RPS.Events.DeathEvent
Humanoid.Died:Connect(function()`
DeathEvent:FireServer()
end)
afterwards just change the leaderstats value of the player in a server script
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
local _stats = player.leaderstats
for _, stat in ipairs(_stats:GetChildren()) do
if stat:IsA("NumberValue") or stat:IsA("IntValue") then
stat.Value = 0
end
end
end)
end)
end)