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

Problem with an If statement?

Asked by 9 years ago

For some reason this always fires the "else" portion in lines 89-93. I can't figure out why. I printed out "term.owner.Value" right before this line of code and it prints out "none" which is exactly the condition that should make it fire the first part, not the else part.

Btw, I set the StringValue owner to "none" by default.

timer1 = game.Workspace.Timer1
timer2 = game.Workspace.Timer2
clickable = true
term = script.Parent
team_color = nil

function refresh_term()
    -- is this needed?
end

function find_team(color)
    for i,v in pairs(game.Teams:GetChildren()) do
        if v.TeamColor == color then
            return v
        else
            -- n/a
        end
    end
end

function cappable(player)
    if tostring(player.TeamColor) ~= team_color and player.TeamColor ~= "Black" then
        team_color = tostring(player.TeamColor)
        return true
    else
        return false
    end
end

function proper_grammar_lol(team)
    if tostring(team) == "FEAR" or tostring(team) == "fear" then
        return "s"
    else
        return "" 
    end
end

function start_timer()

end

function stop_timer(Owner, capturer)
    -- needs to go backwards
end

function cap_term_first_time(team)

    local gui = game.Workspace.GUIpart.SurfaceGui.Frame.MovingFrame
    local limit = 350 -- size of underlying frame
    local i = 0
    local pixels = 3.5 -- pixels per .1 second

    gui.BackgroundColor3 = team.TeamColor.Color

    while i <= limit do
    gui.Size = gui.Size + UDim2.new(0, pixels, 0, 0)
    i = i + pixels
    wait(.1)

    end

    term.owner.Value = tostring(team)

    timer1.change1.BrickColor = team.TeamColor
    timer1.change2.BrickColor = team.TeamColor
    timer1.change3.BrickColor = team.TeamColor
    timer1.change4.BrickColor = team.TeamColor
    timer2.change1.BrickColor = team.TeamColor
    timer2.change2.BrickColor = team.TeamColor
    timer2.change3.BrickColor = team.TeamColor
    timer2.change4.BrickColor = team.TeamColor  

    gui.Parent.TextLabel.Text = tostring(team).." own"..proper_grammar_lol(team).." the terminal."
    gui.Parent.TextLabel.TextColor3 = team.TeamColor.Color  

end

function cap_term(team)
    local m = Instance.new("Message", workspace)
    m.Text = "YES"
end

script.Parent.ClickDetector.MouseClick:connect(function(hit)
    if clickable == true then
        clickable = false

        local player = game.Players:findFirstChild(tostring(hit))
        if cappable(player) then
            if term.owner.Value == "none" then
                cap_term_first_time(find_team(player.TeamColor)) -- CAP TERM FIRST TIME
            else
                cap_term(find_team(player.TeamColor)) -- CAP TERM ANY OTHER TIME
            end
        else
            -- not cappable 
        end
    else
        print("nah b")
    end

    clickable = true
end)
0
From what I see, you have no function callers. LateralLace 297 — 9y
0
What do you mean? fireflame09225 11 — 9y

Answer this question