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

Cannot make a brick clip to the position of the mouse. [?]

Asked by 3 years ago

I am fairly new to scripting and I am requesting quite a bit of help, so if you don't want to help no worries, it would just mean a lot to me!

I am making a brick that when you click it, it will move with your mouse until you click again.

local player = game:GetService("Players").LocalPlayer
local Block = script.Parent
local mouse = player:GetMouse()

Block.ClickDetector.MouseClick:Connect(function(player)
    while wait(Block.ClickDetector.MouseClick) do
        Block.Position = mouse.Position
    end
end)

but there's and error and I can't find it (Obvious) and an explanation with your answer is appreciated so I can learn off your answer!

1 answer

Log in to vote
0
Answered by 3 years ago

Indentions are off, I am on my phone, hopefully this helps, lemme know if there are any errors, also accept this if it works

local player = game:GetService("Players").LocalPlayer
local Block = script.Parent
local mouse = player:GetMouse()

local blockClicked = false


Block.ClickDetector.MouseClick:Connect(function(player)

blockClicked = true 

while wait(0.1) do
if blockClicked == true then
Block.Position = mouse.Position

end     
end
end)


-- Checks if player clicked
mouse.Button1Down:Connect(function()

-- Checks if the block was clicked if then. 
if blockClicked == true then

-- Makes it stop positioning the block
blockClicked = false

end
end) 
0
Doesn't work. BrishedBoomer 29 — 3y
0
What's the error? xXLegendGamerz16Xx 231 — 3y
Ad

Answer this question