So I'm trying to make a grenade toss that aims where the character's mouse location is, as long as that location isn't over 45 studs.
I have a problem with making it accurate. I think it's because the Velocity. But I'm not 100% sure can anyone tell me how I can make it accurate, or show me a script of how I should be doing it?
https://gyazo.com/651522d21b7e48256863470cfe78c8f9
This is what happens. The position that the grenade goes is totally off from the mouse.
game.ReplicatedStorage.Calls.ThermalD.OnServerEvent:connect(function(ForcePlayer,point)
local ForceChar = ForcePlayer.Character
local Players = game.Players:GetChildren()
local anim = ForceChar.Humanoid:LoadAnimation(game.ServerStorage.ThermalDet)
local Det = game.ServerStorage.Detonator:Clone()
local DetRems = game.ServerStorage.DetRemains:Clone()
if (point - ForceChar.HumanoidRootPart.Position).magnitude <= 45
then
anim:Play()
Det.Parent = ForceChar
Det.CFrame = ForceChar.LeftLowerArm.CFrame * CFrame.new(0,0,-1.7)
Det.Velocity = point*3.5
else
return
end
Det.Touched:connect(function()
Det.Velocity = Vector3.new(0,0,0)
Det.RotVelocity = Vector3.new(0,0,0)
Det.Transparency = 1
DetRems.Parent = game.Workspace
DetRems.Position = Det.Position
for i,Player in pairs(Players) do
local iChair = Player.Character
if iChair and iChair ~=ForceChar then
if (Det.Position - iChair.HumanoidRootPart.Position).magnitude <= 16 then
spawn(function()
local anim2 = iChair.Humanoid:LoadAnimation(game.ServerStorage.KnockBack)
anim2:Play()
iChair.Humanoid.WalkSpeed = 0
iChair.Humanoid.Health = iChair.Humanoid.Health - 25
wait(2)
iChair.Humanoid.WalkSpeed = 16
end)
end
end
end
end)
end)
