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

How can i Call a Mouseclick?

Asked by 3 years ago

How can i call a Clickdetector so the Player did not clicked it but the Clickdetector think it was Clicked?

2 answers

Log in to vote
3
Answered by
appxritixn 2235 Moderation Voter Community Moderator
3 years ago

No, you can't truly simulate a mouse click. The best you can do is call the function associated with the ClickDetector.

i.e:

function clicked(player)
    print(("%s clicked this"):format(tostring(player)))
end

ClickDetector.MouseClick:Connect(clicked) -- When a player clicks on the clickdetector

clicked() -- The closest you can get to simulating a button press at the moment

In the example, the function clicked() is associated with the ClickDetector, so calling the function clicked() could 'simulate' a button press, although it will not send a keypress event.

Ad
Log in to vote
0
Answered by 3 years ago

Greetings, I hope this function answers your question.

Put this script in your ClickDetector in workspace.

script.Parent.MouseClick:Connect(function()
      --Whatever goes here will be fired when clicked!
end)

What this function does is give information to the ClickDetector, and fires the code inside of the function.

Making a part Transparent on click:

Make a part and anchor it. Inside the part add a ClickDetector and a script inside.

local part = yourpartlocation

script.Parent.MouseClick:Connect(function()
      part.Transparency = 1
end)

I hope this helps! And remember that this isn't a request site, so try this out yourself.

0
I want to Simulate a Mouseclick i know hot a Clickdetector works 18193883 0 — 3y

Answer this question