#Issue with one of the team values running twice simultaneously

5 messages · Page 1 of 1 (latest)

lyric siren
#

Simple capture point aka terminal script

local terminalfolder = game.ReplicatedStorage.Terminal or game:WaitForChild("ReplicatedStorage"):WaitForChild("Terminal")
local capturervalue = terminalfolder.Capturer or terminalfolder:WaitForChild("Capturer")
local official = terminalfolder.Official or terminalfolder:WaitForChild("Official")
local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local adminlist = {583153}
local touchedrecently = false
local restarted = false

game.Workspace.TerminalPart.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        if official.Value and not touchedrecently then
            if not restarted then
                if capturervalue.Value ~= tostring(game.Players[tostring(hit.Parent)].Team) and tostring(game.Players[tostring(hit.Parent)].Team) ~= "Neutral" then
                    capturervalue.Value = tostring(game.Players[tostring(hit.Parent)].Team)
                    touchedrecently = true
                    task.wait(1)
                    touchedrecently = false
                end
            elseif restarted then
                if hit.Parent:FindFirstChild("Humanoid") and tostring(game.Players[tostring(hit.Parent)].Team) ~= "Neutral" then
                    restarted = false
                    capturervalue.Value = tostring(game.Players[tostring(hit.Parent)].Team).." "
                    capturervalue.Value = tostring(game.Players[tostring(hit.Parent)].Team)
                    touchedrecently = true
                    task.wait(1)
                    touchedrecently = false
                end
            end
        end
    end
end)

https://gyazo.com/6441ffaf3723720d09a9c87559261992

#
capturervalue.Changed:Connect(function()
    if capturervalue.Value == "Team1" or capturervalue.Value == "Team2" then
        for i,v in pairs(terminalfolder:GetChildren()) do
            if v.Name == capturervalue.Value then
                repeat if terminalfolder[v.Name].Value < terminalfolder.TotalPoints.Value and official.Value then terminalfolder[v.Name].Value += 1 task.wait(1) else break end until capturervalue.Value ~= v.Name or terminalfolder[v.Name].Value >= terminalfolder.TotalPoints.Value
            end
        end
    end
end)
#

Both team values are changed with the same code, but only the team2(blue) value glitches and loops twice if not more than twice

#

There's nothing in the terminal folder where all the values are that could make it run a second loop