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

Fix pushing parts in the direction of mouse.?

Asked by
NorteX_tv 101
5 years ago

I got the code kinda working, but not completely. Problem: the part is not rotating with the mouse pointer the right way. Goal: when the tool is held, add velocity to the part in the direction the mouse is pointing. Parts: https://i.imgur.com/Vd9CBrk.png Tool: https://i.imgur.com/ipf4Y6Z.png Code: `local player = game.Players.LocalPlayer local character = player.CharacterAdded:wait() local mouse = player:GetMouse() local engine = workspace.Engine

local tool = script.Parent local equipped = false

local BG = engine.BodyGyro local BV = engine.BodyVelocity

local speed = 50

tool.Equipped:Connect(function() equipped = true BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge) repeat

    BV.Velocity = engine.CFrame.lookVector * speed
    BG.CFrame = CFrame.new(engine.Position, mouse.hit.p)
    wait()

until not equipped

BV.MaxForce = Vector3.new(0,0,0)
BG.CFrame = CFrame.Angles(0,0,0)

end)

tool.Unequipped:Connect(function() equipped = false end)`

No output or errors. The problem here is it's only pushing forward.

Answer this question