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

How to make the Brick sto moving?

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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)
0
IT WORKS :D THANKS RicheeNektar 78 — 8y
Ad

Answer this question