So im trying to make a boss battle that ends when you die || Main Script (Server Script in a ProximityPrompt):
local function Battle()
local plr = game.Players:FindFirstChildOfClass("Player")
local char = plr.Character
local fight = game.ReplicatedStorage.SylumFight.Value
fight = true
local root = char.HumanoidRootPart
wait(20)
for i = 1, 10, 1 do
if fight == true then
local x = math.random(1, 90)
local y = math.random(1, 90)
local z = math.random(1, 90)
local attack = game.ReplicatedStorage.FightPhase1:Clone()
attack.Parent = game.Workspace
attack.Position = root.Position
attack.Script.Disabled = false
attack.Orientation = Vector3.new(x, y, z)
attack.Name = "attack"
wait(1)
else
return false
end
end
local destroy1 = game.ReplicatedStorage.DestroyPhase1:Clone()
destroy1.Position = Vector3.new(-37, 0.5, 13)
destroy1.Parent = game.Workspace
destroy1.Script.Disabled = false
while true do
local block = game.Workspace:FindFirstChild("DestroyPhase1")
if block == nil then
break
end
wait(1)
end
for i = 1, 10, 1 do
if fight == true then
local x = math.random(1, 90)
local y = math.random(1, 90)
local z = math.random(1, 90)
local attack = game.ReplicatedStorage.FightPhase2:Clone()
attack.Parent = game.Workspace
attack.Position = root.Position
attack.Script.Disabled = false
attack.Orientation = Vector3.new(x, y, z)
attack.Name = "attack"
wait(1)
else
return false
end
end
local destroy2 = game.ReplicatedStorage.DestroyPhase2:Clone()
destroy2.Position = Vector3.new(17, 0.5, 12)
destroy2.Parent = game.Workspace
destroy2.Script.Disabled = false
while true do
local block = game.Workspace:FindFirstChild("DestroyPhase2")
if block == nil then
wait(1)
return true
end
end
end
script.Parent.Triggered:Connect(Battle)
Second Script(ServerScript in ServerScriptService):
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char.Humanoid.Died:Connect(function()
print("Died")
game.ReplicatedStorage.SylumFight.Value = false
end)
end)
end)
For some reason it just doesent end the fight, and it prints no errors. (Also Im making a singleplayer game so thats why I have the :FindFirstChildOfClass("Player"))
If anyone could Help I would really appreciate it!

1 comment
Are you trying to kick a player from the game or just simply end the boss fight and teleport them somewhere or something else of the sorts.