Need help with gui script not working right

local InteractionsPart = game.Workspace.WorkspaceInteractions.WardenTeamChange
local TeamToChange = InteractionsPart.TeamChangeValue.Value
local ReplicatedStorageEvent = game.ReplicatedStorage.Static.Events.TeamChange
local PlayerYes = game.Players.LocalPlayer

local OnTeamYes = false

local UserInputYes = game:GetService("UserInputService")

UserInputYes.InputBegan:Connect(function(Keybind, IsTyping)
    local PlayerandPartDistanceYes = (InteractionsPart.Position - PlayerYes.Character:FindFirstChild("HumanoidRootPart").Position).Magnitude
        if not IsTyping then
            if Keybind.KeyCode == Enum.KeyCode.G then
            if PlayerandPartDistanceYes <= 5 then
                if OnTeamYes == false then
                    OnTeamYes = true
                    ReplicatedStorageEvent:FireServer(TeamToChange)
                    InteractionsPart:FindFirstChild("Prompt").Frame.TextLabel.Text = "Leave Team (GC)"
                else
                    OnTeamYes = false
                    InteractionsPart:FindFirstChild("Prompt").Frame.TextLabel.Text = "Join Team (GC)"
                end
            end
        end
    end
end)

The bug is the value of OnTeam is just coming back as true all the time, it is not changing at all

Maybe try

else
      if  OnTeamYes == false then
         InteractionsPart:FindFirstChild("Prompt").Frame.TextLabel.Text = "Join Team (GC)"
end

idk

this did not work but maybe something else will i do not know

oh really sorry, maybe search it up