My game has a shop that has some power ups in it. One of the power ups is the instant kill script. Which lasts the entire length of my game. I have a localscript controlling the shop and a serverscript carrying out the kills.
Localscript:
ShopGUI.kill.Buy.Activated:Connect(function()
game.ReplicatedStorage.KillHumanoid:FireServer()
end)
Serverscript:
ReplicatedStorage.KillHumanoid.OnServerEvent:Connect(function(player)
while wait(0.5) do
workspace[player.Name].Killpart.Touched:Connect(function(hit)
if debounce then return end
debounce = true
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid ~= nil then
local victim = game.Players[humanoid.Parent.Name]
if humanoid ~= player.Character.Humanoid and victim.Team ~= game.Players[player.Name].Team then
humanoid.Health = 0
humanoid.Died:Connect(function()
if isDead then return end
isDead = true
game.Players[player.Name].leaderstats.Kills.Value += 1
isDead = false
end)
wait(0.5)
end
debounce = false
end
end)
end
end)
The issue is with the server script I think. When I buy the power up. For the first time, I am able to kill my friend. My friend dies and then respawns. Everything is well. After he respawns, he comes at me and I can’t seem to kill him a second time. This is the problem because I want the power up to last the whole game, not just one time. I have a while wait(0.5) do
loop just so I can check if I am touching another player every half a second. I have no idea why this is the case and it seems to happen everytime .