What do you want to achieve? I need a script that kills you instantly when you spawn, because apparently, this system I have, doesnt work unless you die once
What is the issue? I cannot make the script nor find it because no one else has this problem
What solutions have you tried so far? looked in the toolbox and youtube, and on the forum. Nada!
local plrs = game:GetService("Players")
plrs.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local h = c:WaitForChild("Humanoid",5)
if h then
h.Health = 0
end)
end)
Sorry for the bad code formatting and variable names, I didn’t have much time.
This code won’t work, because you’re connecting a coroutine and will only run once. Also, don’t use -math.huge as the health or math.huge as you WaitForChild timeout.
Connecting a function automatically creates a new thread.
local Players = game:GetService('Players')
local function KillPlayer(Character)
repeat task.wait(0.5)
if Character:FindFirstChildOfClass("Humanoid") then
Character:FindFirstChildOfClass("Humanoid").Health = 0
end
until not Character.Parent
end
Players.PlayerAdded:Connect(function(Player)
task.spawn(KillPlayer, Player.Character or Player.CharacterAdded:Wait())
Player.CharacterAdded:Connect(KillPlayer)
end)