Hello everyone, I’m trying to make it so that while a player has less than 5 kills, then they keep respawning on a part called ‘arena1team1’ but i’m not sure how to do this…
Here is the part of script where im trying to implement it, as you can see I tried to do it but it just gave me error messages and didnt work.
local function startEvent()
local plr1CurrentKills = 0
local plr2CurrentKills = 0
local SwordGiver = game.ServerStorage.Sword
local Sword1 = SwordGiver:Clone()
local char1 = standingOnArena1Player1.Character
print("Variables working fine")
if char1 then
print("Detected that i'm char1")
local humanoid1 = char1:FindFirstChild("Humanoid")
if humanoid1 then
print("Approved that i'm humanoid")
while plr1CurrentKills < 5 do
print("Detected less than 5 kills")
char1.Humanoid.Died:Connect(function(tag)
print("Detected Death")
plr2CurrentKills = plr2CurrentKills + 1
print("Changed kills value")
standingOnArena1Player1.RespawnLocation = game.Workspace.Arena1Player1
print("Set new location")
end)
Sword1.Parent = standingOnArena1Player1.Backpack
humanoid1:EquipTool(Sword1)
print("Gave sword")
wait(1)
end
standingOnArena1Player1.RespawnLocation = game.Workspace.SpawnLocation
print("Reset the spawn location")
end
end
local Sword2 = SwordGiver:Clone()
local char2 = standingOnArena1Player2.Character
if char2 then
print("Detected that i'm char1")
local humanoid2 = char2:FindFirstChild("Humanoid")
if humanoid2 then
print("Approved that i'm humanoid")
while plr2CurrentKills < 5 do
print("Detected less than 5 kills")
char2.Humanoid.Died:Connect(function(tag)
print("Detected Death")
plr1CurrentKills = plr1CurrentKills + 1
print("Changed kills value")
standingOnArena1Player2.RespawnLocation = game.Workspace.Arena1Player2
print("Set new location")
end)
Sword2.Parent = standingOnArena1Player2.Backpack
humanoid2:EquipTool(Sword2)
print("Gave sword")
wait(1)
end
standingOnArena1Player2.RespawnLocation = game.Workspace.SpawnLocation
print("Reset the spawn location")
end
end
end