I would say use attributes. First, you can do
local HOURS_DEAD = 10
local Players = game:GetService("Players")
Player.PlayerAdded:Connect(function(plr)
local dTime = 0
if plr:GetAttribute("DeathTime") == nil then
plr:SetAttribute("DeathTime", 0)
end
if plr:GetAttribute("Died") == true then
if plr:GetAttribute("DeathTime") ~= nil then
dTime = plr:GetAttriubte("DeatTime")
end
if os.time() - dTime < 3600*HOURS_DEAD then
plr:SetAttribute("Died", true)
local date = os.time() - dTime
plr:Kick("You will respawn in "..date/14400 .. " hours!")
elseif os.time() - dTime > 3600*HOURS_DEAD then
plr:SetAttribute("Died", false)
end
elseif plr:GetAttribute("Died") == nil then
plr:SetAttriubte("Died", false)
end
end)
This code should be able to be put in a Script in ServerScriptService, it basically checks if the player is dead and if they are it kicks them
Finally, you need a code to kill the player. This should work in a script, I just programmed it as if the parent of the script is a kill brick
local Players = game:GetService("Players")
local function killPlayer(plr)
local name = plr:FindFirstAncestorWhichIsA("Model").Name
local player = Players:FindFirstChild(name)
player:SetAttribute("Died", true)
player:SetAttribute("DeathTime", os.time())
player:Kick("You will respawn in 10 Hours!!")
end
script.Parent.Touched:Connect(killPlayer)
I spent a long time on this script I really hope it helped!
The only thing you need to actually kill the player/ban them is this
player:SetAttribute("Died", true)
player:SetAttribute("DeathTime", os.time())
player:Kick("You will respawn in 10 Hours!!")
Where player contains the person's Player object from game:GetService("Players")
1 comment
Hey sorry if my code didn't work you should test it again, I just added respawn system so players can get back into the game