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

if statement running when value isn't true?

Asked by 5 years ago
handle.Touched:connect(function(hit)
        if not pause2 then
            pause2 = true
            if Mouse.Button1Down then
                if humanoid and hit and not hit:isDescendantOf(person) and Mouse.Button1Down and var.Value == true then
                    local target = hit.Parent:WaitForChild("Humanoid", 1)
                    var.Value = false
                    print("Target variable added.")

Specifically, on the part that says "if humanoid and hit and not hit:isDescencentOf(person) and Mouse.Button1Down and var.Value == true then" the statement is running even when the left click on the mouse isn't clicked. Keep in mind that I'm trying to make a sword.

0
"if Mouse.Button1Down then" what? User#19524 175 — 5y
0
Have you defined mouse previously in the script? It'd probably give us better insight on the issue then. Lugical 425 — 5y
0
Mouse.Button1Down is an event, not a boolean. It will alwaya be true. Amiaa16 3227 — 5y
0
Yes, I've defined the mouse. Starflyerz 44 — 5y
0
look into repeat loops if you want a loop to run while a value is not true. (This link is old, but,) http://wiki.roblox.com/index.php?title=User:ElectricBlaze/Lectures/Ch2/Repeat_Loops or https://developer.roblox.com/articles/Roblox-Coding-Basics-Loops (Gotta look for repeat/until loops in previous link). Z0ggg 20 — 5y

Answer this question