So, at the moment I am trying to work on a grenade. It works on the first throw but when I click it again it comes up with the error: The parent BodyVelocity is locked, current parent: NULL, new parent grenade.
Heres the script:
local player = script.Parent.Parent
local mouse = player:GetMouse()
HoldingArm = player:FindFirstChild('RightArm')
Explosion = game.ServerStorage.Explosion
Explosion1 = game.ServerStorage.Explosion.Explosion1
Explosion2 = game.ServerStorage.Explosion.Explosion2
Explosion3 = game.ServerStorage.Explosion.Explosion3
Explosion4 = game.ServerStorage.Explosion.Explosion4
Explosion5 = game.ServerStorage.Explosion.Explosion5
Explosion6 = game.ServerStorage.Explosion.Explosion6
Explosion7 = game.ServerStorage.Explosion.Explosion7
Explosion8 = game.ServerStorage.Explosion.Explosion8
CanThrow = true
Grenade = game.ReplicatedStorage.Grenade:clone()
Bv = Instance.new('BodyVelocity')
b = 1
repeat wait(0.001) until player.Character
Anim = player.Character.Humanoid:LoadAnimation(script.Animation)
mouse.KeyDown:connect(function(key)
if CanThrow == false then return end
if key == "e" then
if b > 5 then return end
CanThrow = false
print('Grenade about to throw')
Grenade.Parent = workspace
Anim:Play()
wait(0.75)
Grenade.CFrame = player.Character.Torso.CFrame*CFrame.new(0,0,0)
Bv.Parent = Grenade
Bv.MaxForce = Vector3.new(1e8,1e8,1e8)
Bv.Velocity = player.Character.Torso.CFrame.lookVector*60
print('Grenade Thrown')
game.Debris:AddItem(Grenade,2)
CanThrow = true
b = b + 1
end
end)
Please help!
PS: There is a grenade in the ServerStorage and the script is local in the starterpack. Also the animation is in the script

2 comments
Thanks!
It works :p