function Explode(F)local q=Instance.new("\069\120\112\108\111\115\105\111\110",workspace)q.ExplosionType=Enum.ExplosionType.NoCraters q.Position=F.Position q.BlastRadius=config.ExplosionRadius.Value F:Destroy()script.Parent:remove()end script.Parent.Throw.OnServerEvent:connect(function(F,q)local Z=Vector3.new(tool.Handle.Position.X,0,tool.Handle.Position.Z)local s=Vector3.new(q.X,0,q.Z)local Q=(Z-s).magnitude local N=q.Y-tool.Handle.Position.Y local t=AngleOfReach(Q,N,config.GrenadeVelocity.Value)tool.Handle.Transparency=1 local T=tool.Handle:Clone()T.Parent=workspace T.Transparency=1 T.CanCollide=true T.CFrame=tool.Handle.CFrame T.Velocity=(CFrame.new(T.Position,Vector3.new(q.X,T.Position.Y,q.Z))*CFrame.Angles(t,0,0)).lookVector*config.GrenadeVelocity.Value spawn(function()if config.ExplodeOnTouch.Value then T.Touched:connect(function(F)if F.Parent~=tool.Parent and F.CanCollide then Explode(T)end end)else wait(config.FuseTime.Value)Explode(T)end end)wait(config.Cooldown.Value)tool.Handle.Transparency=1 end)

function Explode(part)
	local explosion = Instance.new("Explosion", workspace)
	explosion.ExplosionType = Enum.ExplosionType.NoCraters
	explosion.Position = part.Position
	explosion.BlastRadius = config.ExplosionRadius.Value
	part:Destroy()
script.Parent:remove()
end

script.Parent.Throw.OnServerEvent:connect(function(player, mousePosition)
	local handlePos = Vector3.new(tool.Handle.Position.X, 0, tool.Handle.Position.Z) -- remove Y from the equation, it's not needed
	local mousePos = Vector3.new(mousePosition.X, 0, mousePosition.Z) -- ditto
	local distance = (handlePos - mousePos).magnitude -- Get the distance between the handle and the mouse
	local altitude = mousePosition.Y - tool.Handle.Position.Y
	local angle = AngleOfReach(distance, altitude, config.GrenadeVelocity.Value) -- Calculate the angle
	
	tool.Handle.Transparency = 1
	local grenade = tool.Handle:Clone()
	grenade.Parent = workspace
	grenade.Transparency = 1
	grenade.CanCollide = true
	grenade.CFrame = tool.Handle.CFrame
	grenade.Velocity = (CFrame.new(grenade.Position, Vector3.new(mousePosition.X, grenade.Position.Y, mousePosition.Z)) * CFrame.Angles(angle, 0, 0)).lookVector * config.GrenadeVelocity.Value -- Throwing 'n stuff, it probably didn't need to be this long
	spawn(function()
	if config.ExplodeOnTouch.Value then
		grenade.Touched:connect(function(hit)
			if hit.Parent ~= tool.Parent and hit.CanCollide then -- Make sure what we're hitting is collidable
				Explode(grenade)
			end
		end)
	else
		
			wait(config.FuseTime.Value)
			Explode(grenade)
	end
	end)
	wait(config.Cooldown.Value)
	tool.Handle.Transparency = 1
end)
