Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to ask a simple "if then" question for this (details inside)?

Asked by 5 years ago
Edited 5 years ago

QUESTION: Is there a way to ask a simple "if then" condition, if the player has already selected a Team 1 or a Team 2?

Script Questions: Where is it? What kind of script is it? Who uses this to do what?

Answers: It is inside of a GUI button. This is a local script. This allows the player to choose this option as their Team1 or Team2(They can choose if they select this button as Team1 or Team2). When they click the option(this button), It changes the bordercolor of the button to show the player's possession of whichever team they set it for(Team 1 or Team 2).

Okay so this code works:

local debounce = true
local TeamValue = game.ReplicatedStorage:FindFirstChild("Values"):FindFirstChild("CustomTeamValue")
local CustomTeam1 = game.ReplicatedStorage:FindFirstChild("Values"):FindFirstChild("CustomTeam1")
local CustomTeam2 = game.ReplicatedStorage:FindFirstChild("Values"):FindFirstChild("CustomTeam2")

script.Parent.MouseButton1Click:Connect(function()
    if TeamValue.Value == 1 then
        if not debounce then
            return
        end
        debounce = false
        if CustomTeam2.Value == "Patriots" then
            CustomTeam1.Value = "Patriots"
            CustomTeam2.Value = " "
        else
            CustomTeam1.Value = "Patriots"
        end
        --||NFC||--
        local i = 1
        for i = 0,8 do
            script.Parent.Parent["A"..tostring(i + 1)].BorderColor3 = Color3.fromRGB(0,0,0)
            script.Parent.BorderColor3 = Color3.fromRGB(255,255,0)
            wait(0.001)
        end
        local i = 0
        for i = 1,6 do
            script.Parent.Parent["B"..tostring(i + 1)].BorderColor3 = Color3.fromRGB(0,0,0)
            script.Parent.BorderColor3 = Color3.fromRGB(255,255,0)
            wait(0.001)
        end

        --||AFC||--
        local i = 0
        for i = 0,8 do
            script.Parent.Parent.Parent.NFC["A"..tostring(i + 1)].BorderColor3 = Color3.fromRGB(0,0,0)
            script.Parent.BorderColor3 = Color3.fromRGB(255,255,0)
            wait(0.001)
        end
        local i = 0
        for i = 1,6 do
            script.Parent.Parent.Parent.NFC["B"..tostring(i + 1)].BorderColor3 = Color3.fromRGB(0,0,0)
            script.Parent.BorderColor3 = Color3.fromRGB(255,255,0)
            wait(0.001)
        end

        wait(0.1)
        debounce = true

    elseif TeamValue.Value == 2 then
        if not debounce then
            return
        end
        debounce = false
        if CustomTeam1.Value == "Patriots" then
            CustomTeam1.Value = " "
            CustomTeam2.Value = "Patriots"
        else
            CustomTeam2.Value = "Patriots"
        end

        --||NFC||--
        print(script.Parent.Parent.A2)
        local i = 1
        for i = 0,8 do
            script.Parent.Parent["A"..tostring(i + 1)].BorderColor3 = Color3.fromRGB(0,0,0)
            script.Parent.BorderColor3 = Color3.fromRGB(0, 170, 255)
            wait(0.001)
        end
        local i = 0
        for i = 0,6 do
            script.Parent.Parent["B"..tostring(i + 1)].BorderColor3 = Color3.fromRGB(0,0,0)
            script.Parent.BorderColor3 = Color3.fromRGB(0, 170, 255)
            wait(0.001)
        end

        --||AFC||--
        local i = 0
        for i = 0,8 do
            script.Parent.Parent.Parent.NFC["A"..tostring(i + 1)].BorderColor3 = Color3.fromRGB(0,0,0)
            script.Parent.BorderColor3 = Color3.fromRGB(0, 170, 255)
            wait(0.001)
        end
        local i = 0
        for i = 0,6 do
            script.Parent.Parent.Parent.NFC["B"..tostring(i + 1)].BorderColor3 = Color3.fromRGB(0,0,0)
            script.Parent.BorderColor3 = Color3.fromRGB(0, 170, 255)
            wait(0.001)
        end


        wait(0.1)
        debounce = true
    end
end)

(First half of code is for if they selected to make this option Team 1 , and second half is for they selected option for Team 2)

PROBLEM: Example: If they player has selected a Team 2 option. When they go to select a Team 1 option, it changes the Team 2 option's border color back to normal because this script changes the border color of just the parent and changes every single other option's border color to normal.

AGAIN QUESTION: Is there a way to ask a simple "if then" condition, if the player has already selected a Team 1 or a Team 2?

0
could you elaborate on the question im still not understanding it with the 20 options and stuff mattchew1010 396 — 5y
0
Sorry, yeah that was a bad example.. I edited it, hope that helps. If not then ask again MusicalDisplay 173 — 5y
0
why don't you add another debounce in team1 = true or team1 = false? team1 = nil?? if team1 ~= nil then?? i dont really know what ur asking HappyTimIsHim 652 — 5y
0
nah its good i just figured it out MusicalDisplay 173 — 5y

Answer this question