Hello, im having this problem in this script. We dont know why is it not working and we dont know what to do. We are tired of it and we need your help.
Here is the script (please tell us what to change for it to work):
local rs = game:GetService(“ReplicatedStorage”)
local remote = rs:WaitForChild(“StartBombTag”)
remote.Event:Connect(function()
local cd = false
local players = game:GetService(“Players”)
if not game.Workspace.BombtagMap:FindFirstChild(“BombtagMap”) then
local mapClone = game.ServerStorage.Maps.BombtagMap:Clone()
mapClone.Parent = game.Workspace.BombtagMap
local map = mapClone
if not game.Teams:FindFirstChild("BombtagPlayers") then
local newTeam = Instance.new("Team")
newTeam.Name = "BombtagPlayers"
newTeam.TeamColor = BrickColor.DarkGray()
newTeam.Parent = game.Teams
end
if not game.Teams:FindFirstChild("BombtagBomb") then
local newTeam = Instance.new("Team")
newTeam.Name = "BombtagBomb"
newTeam.TeamColor = BrickColor.Black()
newTeam.Parent = game.Teams
end
local bombtagPlayers = {}
local function GetBomb()
for i, player in next, game.Players:GetChildren() do
if player.Team == game.Teams.BombtagBomb then
return player
end
end
end
local function endBombTag()
local player = nil
for i, playerr in next, bombtagPlayers do
player = game.Players:FindFirstChild(playerr)
end
for i, player in next, game.Players do
if table.find(bombtagPlayers, player.Name) then
table.remove(bombtagPlayers, table.find(bombtagPlayers, player.Name))
player.Team = game.Teams.Neutral
player.Character.Humanoid:TakeDamage(110)
end
end
game.ReplicatedStorage.BombtagEnded:FireAllClients(player.Name)
workspace.BombtagMap.BombtagMap:Remove()
end
local function SwitchBomb(player)
print(player)
local char = player.Character
print(char)
local guiClone = game.ServerStorage.BombGui:Clone()
guiClone.Parent = char.Head
local soundClone1 = game.ServerStorage.BombSound:Clone()
local soundClone2 = game.ServerStorage.BombExplode:Clone()
soundClone1.Parent = char.Head
soundClone2.Parent = char.Head
soundClone1:Play()
char.Humanoid.WalkSpeed = 26
player.Team = game.Teams.BombtagBomb
game.ReplicatedStorage.BombChanged:FireAllClients(player.Name)
local currentBomb = GetBomb()
currentBomb.Character.Head.BombGui:Remove()
currentBomb.Character.Head.BombSound:Remove()
currentBomb.Team = game.Teams.BombtagPlayer
end
local function StartTimer()
local time = 20
repeat
wait(1)
time -= 1
until
time == 0
local amount = 0
for i, player in next, game.Players:GetChildren() do
if player.Team == game.Teams.BombtagBomb then
local char = player.Character
player.Team = game.Teams.Neutral
char.Humanoid:TakeDamage(110)
char.Head.BombExplode:Play()
if table.find(bombtagPlayers, player.Name) then
table.remove(bombtagPlayers, table.find(bombtagPlayers, player.Name))
end
wait(2.5)
local randomBomb = game.Players:FindFirstChild(bombtagPlayers[math.random(1, #bombtagPlayers)])
randomBomb.Team = game.Teams.BombtagBomb
randomBomb.Character.Humanoid.WalkSpeed = 26
local guiClone = game.ServerStorage.BombGui:Clone()
guiClone.Parent = randomBomb.Character.Head
local soundClone1 = game.ServerStorage.BombSound:Clone()
local soundClone2 = game.ServerStorage.BombExplode:Clone()
soundClone1.Parent = randomBomb.Character.Head
soundClone2.Parent = randomBomb.Character.Head
soundClone1:Play()
randomBomb.Character.HumanoidRootPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:FindFirstChild(hit.Parent.Name)
SwitchBomb(player)
end
end)
StartTimer()
end
end
for i, playerr in next, bombtagPlayers do
amount += 1
end
if amount == 1 then
endBombTag()
end
end
local function ChooseBomb()
print(bombtagPlayers)
local randomBomb = game.Players:FindFirstChild(bombtagPlayers[math.random(1, #bombtagPlayers)])
randomBomb.Team = game.Teams.BombtagBomb
randomBomb.Character.Humanoid.WalkSpeed = 26
local guiClone = game.ServerStorage.BombGui:Clone()
guiClone.Parent = randomBomb.Character.Head
local soundClone1 = game.ServerStorage.BombSound:Clone()
local soundClone2 = game.ServerStorage.BombExplode:Clone()
soundClone1.Parent = randomBomb.Character.Head
soundClone2.Parent = randomBomb.Character.Head
soundClone1:Play()
randomBomb.Character.HumanoidRootPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:FindFirstChild(hit.Parent.Name)
SwitchBomb(player)
end
end)
StartTimer()
end
for i, player in next, players:GetChildren() do
local char = player.Character
if player.Team == game.Teams.Trainer or player.Team == game.Teams.Leader then
local spawns = {}
for i, spawnn in next, map.TrainerSpawns:GetChildren() do
table.insert(spawns, spawnn)
end
local randomSpawn = spawns[math.random(1, #spawns)]
char.HumanoidRootPart.CFrame = CFrame.new(randomSpawn.Position.X, randomSpawn.Position.Y + 5, randomSpawn.Position.Z)
char.Humanoid.WalkSpeed = 25
else
local spawns = {}
for i, spawnn in next, map.Spawns:GetChildren() do
table.insert(spawns, spawnn)
end
local randomSpawn = spawns[math.random(1, #spawns)]
char.HumanoidRootPart.CFrame = CFrame.new(randomSpawn.Position.X, randomSpawn.Position.Y + 5, randomSpawn.Position.Z)
player.Team = game.Teams.BombtagPlayers
table.insert(bombtagPlayers, player.Name)
char.Humanoid.WalkSpeed = 25
end
end
ChooseBomb()
end
end)