Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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


2 comments

0

So in short, the only way to do this is to use ...MouseButton1Click:Connect(function() ?

0

Yes.

1 answer

✓ Accepted answer

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

4 comments

0

Got it!

0

LOL

0

:') at least accept his answer

0

rubenkan big dum dum

This discussion is preserved as it was. New answers, comments, and votes are closed.