I am creating a tool that spawns a part that is suppose to spin and go in same the direction where the character is facing. Right now, the forces are applied, but it sometimes goes diagonal from the player, which I don’t want. You can test it here.
I tried removing the rotational force, but it didn’t affect anything. One thing I’m unsure about is that if I’m applying the body velocity’s velocity correctly. Any help is appreciated!
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local FORCE = 400
tool.Activated:Connect(function()
local part = Instance.new("Part")
part.Position = handle.Position - Vector3.new(0,2.5,0)
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(FORCE,FORCE,FORCE)
bodyVelocity.P = FORCE
bodyVelocity.Velocity = humanoidRootPart.CFrame.LookVector * FORCE -- supposed to move where character is facing at
bodyVelocity.Parent = part
part.Parent = workspace
part:ApplyAngularImpulse(Vector3.new(0,FORCE,0)) -- applies rotation
wait(1)
bodyVelocity:Destroy()
end)
you could try spawning the part more in front of the player so that it doesn’t collide with the player’s legs. it’s collosion with the player may be the course of it’s offset.
I think it’s the rotation that is offsetting the part. Try making the part uncollideable and maybe try using “BodyAngularVelocity”, which is a body mover. Instead of :ApplyAngularImpulse
This should be a simple fix, but it still doesn’t work properly. I updated the place with the code you typed.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local FORCE = 400
tool.Activated:Connect(function()
local part = Instance.new("Part")
part.CFrame = handle.CFrame * CFrame.new(0,0,-2)
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(FORCE,FORCE,FORCE)
bodyVelocity.P = FORCE
bodyVelocity.Velocity = humanoidRootPart.CFrame.LookVector * FORCE -- supposed to move where character is facing at
bodyVelocity.Parent = part
part.Parent = workspace
--part:ApplyAngularImpulse(Vector3.new(0,FORCE,0)) -- applies rotation
wait(1)
--bodyVelocity:Destroy()
part:Destroy()
end)