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

[Solved] Can you use an action in a if statement?

Asked by 5 years ago
Edited 5 years ago

Can you use an action(ex. MouseButton1Click) in an if statement?[in many ways] Not only

~~if script.Parent.MouseButton1Click then~~ a wrong example


IN MANY WAYS


0
So in short, the only way to do this is to use ...MouseButton1Click:Connect(function() ? tree_tree00 48 — 5y
0
Yes. DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
5 years ago
Edited 5 years ago

You can wait for an event to happen or run a function when the event occurs. Using an event in a statement doesn't make any sense.

To wait for an event you can do Event:Wait() instead of Event:Connect(function)

You could also check if the mouse is down in your if statement by putting it in a variable

local Mouse = game.Players.LocalPlayer:GetMouse()
local MouseDown = false
Mouse.Button1Down:Connect(function()
    MouseDown = true
end)
Mouse.Button1Up:Connect(function()
    MouseDown = false
end)


--somewhere in ur code
if MouseDown then
0
Got it! tree_tree00 48 — 5y
0
LOL Elixcore 1337 — 5y
0
:') at least accept his answer Elixcore 1337 — 5y
0
rubenkan big dum dum User#24403 69 — 5y
Ad

Answer this question