Hi all, so in my game I’m planning to have a hammer that propells you forward, just like the Jade Hammer in Roblox BedWars (yes im a fan of that game).
However, I’m using BodyVelocity and cannot get the Test Zombie to move forward.
What’s happening:
Sorry for the lag btw, I’m using the default Roblox recorder.
Image:
ServerCode:
local tool = script.Parent
local remote = tool:WaitForChild("BlastEvent")
remote.OnServerEvent:Connect(function(player, target)
if target then
if target.Parent:FindFirstChild("Humanoid") then
local root = target.Parent.HumanoidRootPart
local velocity = Instance.new("BodyVelocity")
velocity.MaxForce = Vector3.new(6000,6000,6000)
velocity.Velocity = Vector3.new(-100,0,0)
velocity.Parent = root
wait(0.5)
velocity:Destroy()
end
end
end)
ClientCode:
local tool = script.Parent
local remote = tool:WaitForChild("BlastEvent")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
tool.Activated:Connect(function()
remote:FireServer(mouse.Target)
end)
If anyone can help me out, please let me know!
Thanks!
EDIT: Reason why I did “velocity.Velocity = Vector3.new(-100,0,0)” was because I was playing around with it.
The issue that I could see (from your video and your code) is that you apply force on the x-axis. To move a model forward/backward, the BodyVelocity must utilize the z-axis aspect of its Velocity property, in which case, your script would look like this:
local tool = script.Parent
local remote = tool:WaitForChild("BlastEvent")
remote.OnServerEvent:Connect(function(player, target)
if target then
if target.Parent:FindFirstChild("Humanoid") then
local root = target.Parent.HumanoidRootPart
local velocity = Instance.new("BodyVelocity")
velocity.MaxForce = Vector3.new(6000,6000,6000)
velocity.Velocity = Vector3.new(0,0,100) -- 0,0,100 moves the zombie backwards, while 0,0,-100 moves it forwards
velocity.Parent = root
wait(0.5)
velocity:Destroy()
end
end
end)