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

why does this always equal false?[unsolved]

Asked by 8 years ago
if mouse.Target.BrickColor == BrickColor.new("New Yeller") and player.leaderstats.level.Value >= 1 then
                    _G.q = false
                    thing()
                elseif mouse.Target.BrickColor == BrickColor.new("Deep orange") and player.leaderstats.level.Value > 5 then
                    _G.q = true
                elseif mouse.Target.BrickColor == BrickColor.new("Deep orange") and player.leaderstats.level.Value >= 5 then
                    _G.q = false
                    thing()
                elseif mouse.Target.BrickColor == BrickColor.new("Lime green") and player.leaderstats.level.Value > 10 then
                    _G.q = true
                elseif mouse.Target.BrickColor == BrickColor.new("Lime green") and player.leaderstats.level.Value >= 10 then
                    _G.q = false
                    thing()
end

where mouse = game.Players.LocalPlayer:GetMouse() and thing() is a function that works i did a print(_G.q), and it printed false. always printed false, no matter what, what it's supposed to do is if the mouses targets brickcolor is orange, and my level is less then 5, it's supposed to make _G.q true, but it doesn't. any help?

1 answer

Log in to vote
0
Answered by 8 years ago

Your problem is in the way the script is ordered. I see that the only reason "true" would return is if the third argument was true, but the problem is that if the value is bigger than 10 then it is definitely bigger than 5 meaning your first argument will return false right away instead of moving on to any other arguments. Try ordering your script like this:

if mouse.Target.BrickColor == BrickColor.new("New Yeller") and player.leaderstats.level.Value >= 1 then
                    _G.q = false
                elseif mouse.Target.BrickColor == BrickColor.new("Deep orange") and player.leaderstats.level.Value > 10 then
                    _G.q = true
                    thing()
                elseif mouse.Target.BrickColor == BrickColor.new("Deep orange") and player.leaderstats.level.Value > 5 then
                    _G.q = true
                elseif mouse.Target.BrickColor == BrickColor.new("Deep orange") and player.leaderstats.level.Value >= 5 then
                    _G.q = false
                    thing()
                elseif mouse.Target.BrickColor == BrickColor.new("Lime green") and player.leaderstats.level.Value >= 10 then
                    _G.q = false
                    thing()
end

Now the script will always check if the value is greater than 10, before moving on to seeing if its bigger than 5. Hope this helped, feel free to ask any questions.

0
hmm, it still only printed false ScriptsAhoy 202 — 8y
0
and i meant that if it is less then 5 or ten, not greater than if the player does not have at least level 10 for the lime green, then _G.q = true is what im going for ScriptsAhoy 202 — 8y
Ad

Answer this question