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

How can I run a clicked event without using a mousedetector, buttongui, or tool?

Asked by
obcdino 113
8 years ago

I'm trying to make a system that moves parts, the only problem is that I want to use it without buttongui's, tools, or mousedetectors. (i.e Miner's Haven)

My script (1'st line I don't know how to use the connection line, so I guessed :p)

local mouse = game.Players.LocalPlayer:GetMouse() -- I COULD USE HELP HERE ._.
mouse.MouseClick:connect(function()
position = mouse.hit.p
game.Workspace.Part.Position = position
end

I will accept your answer if it is successful!

1 answer

Log in to vote
0
Answered by 8 years ago

First, MouseClick is wrong. You need to use Button1Down or Button1Up

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:connect(function()
position = mouse.hit.p
game.Workspace.Part.Position = position
end)

This should work.

0
Oh, sorry. I just saw that mouseclick was wrong so i fixed it, but you basically had the right connection line. TheBigCoder 25 — 8y
0
EDIT: It's not working (tried both script types) obcdino 113 — 8y
0
It worked perfectly for me. I use a local script, and also make sure to change the line 5 for the right position of the part TheBigCoder 25 — 8y
0
I'm just going to use a tool ;-; obcdino 113 — 8y
Ad

Answer this question