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

How to make the Brick sto moving?

So I have a 'thing' that needz to be positioned where the mouse points towards so I got this script:

local p = game.Players.LocalPlayer
local m = p:GetMouse()


m.Button1Down:connect(function()
	while m.Button1Down do
		if m.Target ~= nil then
			if m.Target.Parent ~= nil then
				if m.Target.Parent.Name == "Move" then
					m.Target.Position = m.hit.p
				end
			end
		end
		m.Move:wait()
	end
end)

and it works just fine the onoy problem here is: The loop is not going to stop!

1 answer

✓ Accepted answer

Use a variable instead of checking m.Button1Down.

local mouseDown=false

m.Button1Down:connect(function()
    mouseDown=true
    while mouseDown do
        if m.Target ~= nil then
            if m.Target.Parent ~= nil then
                if m.Target.Parent.Name == "Move" then
                    m.Target.Position = m.hit.p
                end
            end
        end
        m.Move:wait()
    end
end)
m.Button1Up:connect(function() mouseDown=false end)

1 comment

0

IT WORKS :D THANKS

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