Hello,

I have this script below which is my round based system for a minigame.

However, when a player dies it will just keep respawning them inside the lava and it will keep dying until the lava reaches the top.

I need help with the fact when someone dies it doesn't keep taking them into the round and switching them into the 'lobby team'

******Solutions i've tried so far

I first tried to put the function mod script into the main script then that failed then I tried to put it into the kill script and switch the team still failed lol

Please help me - whats going wrong? any ideas?

Thanks Lani_005

--main script

local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local funMod = require(game.ServerScriptService.FunctionModScript)
local gameOver = true
local gameTime = 240
local lobbySpawn = game.Workspace.LobbySpawn
local Tube1Spawn = game.Workspace.Tube1Spawn

local InSessionTeam = Teams.InSession
local LobbyTeam = Teams.Lobby

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)

		local isPlaying = Instance.new ("BoolValue", character)
		isPlaying.Name = "PlayingGame"
		isPlaying.Value = false

		while wait(1)do
			if gameOver then
				gameOver = funMod.WaitForGame(gameOver)
			else
				if gameTime ~= 0 then
					if character.PlayingGame.Value == false then
						character.PlayingGame.Value = true
						
						player.Team = InSessionTeam
						character.HumanoidRootPart.CFrame = Tube1Spawn.CFrame + Vector3.new(0,5,0)
						
					end
					print("Game Time Remaining "..tostring(gameTime).." Seconds.")
					gameTime = gameTime -1 
					
					game:GetService('Players').PlayerAdded:Connect(function(player)
						player.CharacterAdded:Connect(function(character)
							 character:WaitForChild("Humanoid").Died:Connect(function() 
								player.PlayingGame.Value = false
							
							
							end)
						end)
					end)
				else
					if character.PlayingGame.Value == true then
						character.PlayingGame.Value = false
						
						player.Team = LobbyTeam
						character.HumanoidRootPart.CFrame = lobbySpawn.CFrame + Vector3.new(0,5,0)
					end
					gameOver= true 
					gameTime = 240
				end
			end
		end
	end)
end)



--functionmodscript

local waitTime = 30

local funMod = {}

function funMod.WaitForGame(gameOver)
	if waitTime == 0 then 
		waitTime = 30
		return false
	else
		waitTime = waitTime -1
		print("Intermission - Game Starting in "..tostring(waitTime).." Seconds.")
		return true
	end
end

return funMod
--kill script when collision with lava
-- This script is when the player touches the brick they will instanly die 

script.Parent.Touched:connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.Humanoid.Health = 0 
	end
end)

2 comments

0

konnichiwa!! V ;3

0

Hi - do you have any ideas?