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!
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)