Script just works one time

Hello I’m making a random map picker script but it just works one time. And then it don’t works anymore.

Script:

local randomPlayer

function DeleteCurrentMap()
for i,v in pairs(workspace.CurrentMap:GetChildren()) do
	v:Desroy()
end
end

function PickMap()
    local MapsFolder = game.ReplicatedStorage.Maps:GetChildren()
    local selectedMap = math.random(1, #MapsFolder)
    local map = MapsFolder[selectedMap]:Clone()
    map.Parent = workspace.CurrentMap
end

function TeleportPlayersMap()
    local SpawnsFolder = workspace.CurrentMap:FindFirstChild("Map").Spawns:GetChildren()
    local selectedSpawn = SpawnsFolder[math.random(1, #SpawnsFolder)]
    for i,v in pairs(game.Players:GetPlayers()) do
	    v.Character.HumanoidRootPart.CFrame = CFrame.new(selectedSpawn.Position)
   end
end

game.ReplicatedStorage.StartGame.Event:Connect(function()
    local Players = game:GetService("Players"):GetPlayers()
    DeleteCurrentMap()
    wait(1)
    PickMap()
    wait(5)
    TeleportPlayersMap()
    if #Players > 0 then
    randomPlayer = Players[math.random(#Players)]
    local character = randomPlayer.Character
    character.Humanoid:AddAccessory(game.ReplicatedStorage.BombGame:Clone())
    game.ReplicatedStorage.BombStartGui:FireClient(randomPlayer)
 end
end)

Script:

local Players = game:GetService("Players")

function GetPlayers()
repeat
	wait(3)
	if #Players:GetPlayers() <= 3 then
		game.ReplicatedStorage.WaitPlayersClient:FireAllClients()
	end
until #Players:GetPlayers() >= 3
game.ReplicatedStorage.WaitPlayersDone:FireAllClients()
wait(1)
game.ReplicatedStorage.RoundStartingClient:FireAllClients()
wait(3)
game.ReplicatedStorage.StartGame:Fire()
end


wait(5)
GetPlayers()

game.ReplicatedStorage.RoundOver.Event:Connect(function()
    game.ReplicatedStorage.RoundOverClient:FireAllClients()
    wait(5)
    GetPlayers()
end)

Script:

function TeleportBack()
for i,player in pairs(game:GetService("Players"):GetPlayers()) do
	player:LoadCharacter()
end
end

game.ReplicatedStorage.ExplodeBomb.OnServerEvent:Connect(function(player, character)
local bomb = character:FindFirstChild("BombGame")
local humanoid = character:FindFirstChild("Humanoid")
if bomb and humanoid then
	local explosion = Instance.new("Explosion", bomb)
	explosion.Position = bomb.Handle.Position
	humanoid.Health = 0
	game.ReplicatedStorage.RoundOver:Fire()
	wait(3)
	TeleportBack()
 end
end)

Is the RemoteEvent being fired more times or just one time?

It gets fired when the round is over or is the first round.

Could we see where this Bindable Event first fires?

Hello, I added that scripts now.

I haven’t read the entire script yet, but I noticed that you have a typo here, ”v:Desroy()” should be ”v:Destroy()”

1 Like

Thank you very much, that fixed the problem.

would recommend just using

workspace.CurretMap:ClearAllChildren()
1 Like