I really need help on this

so i just followed a tutorial so it was premade and did a little scripting for my preference but one problem
the spawn(round) keeps going onto each other so theres 2 i want if if blue touches that part it removes the current one then spawns a new one heres the script

function BlueWin()
staus.Value = “Blue Has Won”
rep.RoundEnd:FireAllClients(BlueTeamCount, remainingBlue, RedTeamCount, remainingRed)
end

game.Workspace.Win.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“HumanoidRootPart”) then
hit.Parent.HumanoidRootPart.CFrame = location.CFrame + Vector3.new(0,0,0)
BlueWin()
spawn(round)
end
end)

spawn(round)

1 Like

Could you PLEASE format all the code into

code blocks 

It Makes it so much easier for me and other scripters to understand what the hell is going on

2 Likes

I don’t know what code blocks is but I made it shorter to the specific problem

You can try adding a flag to your code.

Something like:

local roundSpawned = false -- Keep track of whether the round has been spawned

and then

function BlueWin()
    status.Value = "Blue Has Won"
    rep.RoundEnd:FireAllClients(BlueTeamCount, remainingBlue, RedTeamCount, remainingRed)
    roundSpawned = false -- Reset the flag when a new round starts
end

and finally

game.Workspace.Win.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("HumanoidRootPart") then
        hit.Parent.HumanoidRootPart.CFrame = location.CFrame + Vector3.new(0, 0, 0)
        BlueWin()
        
        if not roundSpawned then
            roundSpawned = true
            spawn(round)
        end
    end
end)

I can’t confirm that this will work, but hopefully this helps.

Ok thanks I will try it. Hopefully it works

Edit: It didn’t work