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

How would I make this Force script work??

Asked by 8 years ago
--May the force be with you :P

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

local deb = false


local function onKeyDown( key )
    if key == "f" then
        if deb == false then
            deb = true

            print("["..plr.Name.." is changing to force mode]")

            mouse.Button1Down:connect(function(click)
                if mouse.Target:FindFirstChild("canForce") then
                    local bp = Instance.new("BodyPosition", mouse.Target)
                    bp.MaxForce = Vector3.new(400000,400000,400000)
                    mouse.Target.BrickColor = BrickColor.new("Really blue")
                    while true do wait()
                        bp.Position = mouse.Position --here is where i need help
                    end
                end
            end)


            wait(1)
            deb = false
        end
    end
end
mouse.KeyDown:connect(onKeyDown)

I need the brick to follow wherever the mouse goes on an X,Y,Z axis but it smoothly transitions to one point to the next not teleportation effect

1 answer

Log in to vote
0
Answered by
Spectrobz 140
8 years ago

You might wanna use the Lerp method to move the part smoothly.

Take a look there: http://wiki.roblox.com/index.php?title=CFrame#Methods

You will need make the function overridable for whenever the mouse moves, but it's easy to do if you take a moment to think.

Ad

Answer this question