Note:- this is my first topic on devforum. if you believe this is not on the right category please guide me or possibly provide a link. Thank You For Reading this Post
So i have made a Function which simply Adds a Velocity to the Tools handle(Sorry ik im using “.” Operator but the Issue is Different) and rotates it randomly for more realistic throw. the problem is that if this function executes when player is moving, the player will get back his/her tool.
Script:-
function ThrowObject(plr,Object,Power)
local ObjectExistsInPlayerBackPack = plr.Backpack:FindFirstChild(Object)
local Humanoid = plr.Character.Humanoid
if ObjectExistsInPlayerBackPack and Humanoid then
local PlayerPosition = plr.Character.PrimaryPart.Position
local LookVector = plr.Character.PrimaryPart.CFrame.LookVector
ObjectExistsInPlayerBackPack.Parent = workspace
ObjectExistsInPlayerBackPack.Handle.Position = Vector3.new(PlayerPosition.X,PlayerPosition.Y+5,PlayerPosition.Z)
ObjectExistsInPlayerBackPack.Handle.Rotation = Vector3.new(math.random(1,90),math.random(1,90),math.random(1,90))
ObjectExistsInPlayerBackPack.Handle.AssemblyLinearVelocity = LookVector * Power
else
warn("No Tool or Humanoid")
end
end