Hello I’m trying to make my boss throw a rock forward the way he’s facing, I’ve got the animation and everything working but for some reason I can’t get the throwing part just right and I’ve looked for answer and nothing has showed up am I using body velocity wrong?
The rock is anchored and CanCollide is turned off.
Video/GIF:
https://i.gyazo.com/52cfd68e91cb530c5295ad89648875ed.mp4
The Code for the attack:
local function ThrowRock()
local Rock = script.RealRockMesh:Clone()
Rock.Position = script.Parent.HumanoidRootPart.Position
Rock.Parent = game.Workspace
local bodyVel = Instance.new("BodyVelocity")
bodyVel.MaxForce = Vector3.new(5000,5000,5000)
bodyVel.Velocity = script.Parent.HumanoidRootPart.CFrame.LookVector*-25
bodyVel.Parent = Rock
Rock.Anchored = false
Rock.Transparency = 0
Rock.Touched:Connect(function(hit)
if not db then
db = true
local char = hit.Parent
if char:FindFirstChild("Humanoid") and Players:FindFirstChild(char.Name) then
task.wait(0.05)
local function MakeKnockback()
local velo = Instance.new("BodyVelocity",workspace:FindFirstChild(char.Name).PrimaryPart)
velo.MaxForce = Vector3.new(10000000,10000000,1000000)
velo.P = 1000000
local ConvictHRP = script.Parent.PrimaryPart
local VictimHRP = char.PrimaryPart
local Angle = ((VictimHRP.Position - ConvictHRP.Position) * Vector3.new(10,0,10)).Unit * 50 + Vector3.new(0,25,0)
velo.Velocity = Angle
task.wait(0.1)
velo:Destroy()
end
if Players:FindFirstChild(char.Name) then
char.Humanoid.Health -= RockDamage
MakeKnockback()
Rock.Earth.Enabled = true
task.wait(0.5)
Rock:Destroy()
end
end
db = false
end
end)
end