the problem is is that it’ll kill sure but after a certain number of times it won’t change the player’s health to 0 to kill them. it’ll be really low instead. tysm!
script:
plrcheckEvent.OnServerEvent:Connect(function(myplr, state)
plrchoiceUI.Enabled = false
--if clicked no
if state == "no" then
if selectedButton then
selectedButton.ImageColor3 = unselectedColor
end
end
--if clicked yes
if state == "yes" then
if selectedButton then
selectedButton.ImageColor3 = unselectedColor
local findPlr = plrs:FindFirstChild(selectedButton.Name)
if findPlr and findPlr ~= myplr then
closeUI:FireClient(myplr)
if findPlr.Character.Humanoid.Health > 0 then
findPlr.Character.Humanoid.Health = 0
findPlr.CharacterAppearanceLoaded:Connect(function(c)
wait(.5)
local hum:Humanoid = c.Humanoid
hum.Health = 0
end)
end
else
errorUIEvent:FireClient(myplr)
end
end
end
end)
I tried to work the problem and it works for the most part but I had some issues with an attribute bool I made that seems to reset along with the character reloading. Anyway here’s what I did, it kills the player over and over and you can find a way to automate it.
--//LOCALSCRIPT
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local button = script.Parent
button:GetAttributeChangedSignal("LoopKill"):Connect(function()
local loopKillValue = button:GetAttribute("LoopKill")
if loopKillValue then
print("Attribute is true")
RemoteEvent:FireServer(loopKillValue)
else
print("Attribute is false")
end
end)
-- Toggle the LoopKIll attribute value when the button is clicked
button.MouseButton1Up:Connect(function()
local currentLoopKillValue = button:GetAttribute("LoopKill")
button:SetAttribute("LoopKill", not currentLoopKillValue)
end)
--//SERVERSCRIPT
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local debounce = {} --attempting to silence multiple print entries
game.Players.PlayerAdded:Connect(function(player)
debounce[player] = false
player.CharacterAdded:Connect(function(character)
RemoteEvent.OnServerEvent:Connect(function(player, bool)
if not debounce[player] and bool == true and character and character:FindFirstChild("Humanoid") then
debounce[player] = true
local timer = 5
while timer > 0 do
print("Time till death ", timer)
timer = timer - 1
wait(1)
end
if character:FindFirstChild("Humanoid") then
character.Humanoid.Health = 0
end
task.wait()
debounce[player] = false
end
end)
character.Humanoid.Died:Connect(function()
repeat task.wait(1)
print("Waiting for character to reload")
until player.Character and player.Character:FindFirstChild("Humanoid")
end)
end)
end)