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

"If" statement not reading?

Asked by
Paldi 109
5 years ago

Im making a gui button that when i click on it, it puts my character in a certain team but if the team is full it will make the button blink and say its already filled, the thing is, when the said team is full, its not doing anything (not even printing the "wut" part). joining the team works and if its full it wont try to add more players than it should.

function OnClicked()
    local w = script.Parent.Parent:WaitForChild("Main")
    local _Main = require(script.Parent.Parent.Main)
    local actual = script.Parent.Parent.Actual
    local amount = game.ReplicatedStorage.Role:FindFirstChild(script.Parent.Name)
    local color = script.Parent.BackgroundColor3
    if actual.Value ~= script.Parent.Name then
        if amount.Amount.Value >= amount.Max.Value then --its like this part doesnt exists
            print("wut?")
            script.Parent.Text = "Already Filled!"
            for i= 1,3 do
                script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
                wait(.2)
                script.Parent.BackgroundColor3 = Color3.fromRGB(color)
                wait(.2)
            end
            script.Parent.Text = script.Parent.Name
            else                                            -- but from here it works
            actual.Value = script.Parent.Name
            amount.Amount.Value = amount.Amount.Value+1
            _Main.Play()
        end
    end
end


script.Parent.MouseButton1Click:Connect(OnClicked)
0
Amount.Value is less than max value? HappyTimIsHim 652 — 5y
0
well it doesnt print it Paldi 109 — 5y
1
ur script is rly confusing u should try arranging it maybe ull find the problem like that TheluaBanana 946 — 5y
1
it doesn't print anything after else so yeah HappyTimIsHim 652 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
function OnClicked()
    local w = script.Parent.Parent:WaitForChild("Main")
    local _Main = require(script.Parent.Parent.Main)
    local actual = script.Parent.Parent.Actual
    local amount = game.ReplicatedStorage.Role:FindFirstChild(script.Parent.Name)
    local color = script.Parent.BackgroundColor3
    if not actual.Value == script.Parent.Name then
        if amount.Amount.Value >= amount.Max.Value then --its like this part doesnt exists
            print("wut?")
            script.Parent.Text = "Already Filled!"
            for i= 1,3 do
                script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
                wait(.2)
                script.Parent.BackgroundColor3 = Color3.fromRGB(color)
                wait(.2)
            end
            script.Parent.Text = script.Parent.Name
            else                                            -- but from here it works
            actual.Value = script.Parent.Name
            amount.Amount.Value = amount.Amount.Value+1
            _Main.Play()
        end
    end
end


script.Parent.MouseButton1Click:Connect(OnClicked)

u do ==

0
lol TheluaBanana 946 — 5y
Ad

Answer this question