Help with value change script please here

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
                    InteractionsPart:FindFirstChild("Prompt").Frame.TextLabel.Text = "Leave Team (GC)"
                    OnTeamYes = false
                    InteractionsPart:FindFirstChild("Prompt").Frame.TextLabel.Text = "Join Team (GC)"

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

Hey! I understand you’ve provided your code and mentioned there’s a bug, but it’d be really helpful if you can tell us the overarching objective of your code.

What exactly are you trying to do? I can provide a base you can work with afterward.

1 Like

nevermind it was fixed the problem was it was reset on spawn and the script was in StarterGui so I put resetonspawn off for the billboardgui and i put the script in starterplayerscripts and it worked!!