I'm a little confused. pretty sure I can't use a function in a if statement like I did but I don't know the alternative. basically just trying to print "done" if the part is hovered over by the mouse and clicked. any help would be appreciated
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local function clicked() mouse.Button1Down:connect(function() end) end mouse.move:connect(function() if mouse.Target == game.Workspace.Part and clicked() then print("done") end end)
There are many ways to achieve this but the easiest would be by adding a clickdetector
to the part
and then using the MouseClick
event
example:
local part = workspace.Part local ClickDetector = Instance.new("ClickDetector") -- u can add the clickdetector manually into workspace or using script, your choice ClickDetector.Parent = part ClickDetector.MouseClick:Connect(function() print("done") end)
see this article over clickdetector
and u can use functions in if statements