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

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

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

✓ Accepted answer

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.

4 comments

0

Oh, sorry. I just saw that mouseclick was wrong so i fixed it, but you basically had the right connection line.

0

EDIT: It's not working (tried both script types)

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

0

I'm just going to use a tool ;-;

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