function ProjectileReplication.ReplicateThrowable(y,u,l,D)if RunService:IsServer()then local M=y:GetSpawnedThrowable()local t=M:Clone()t:SetAttribute("\079\119\110\101\114\073\068",D.UserId)local o=t.PrimaryPart t:SetPrimaryPartCFrame(CFrame.new(u+l*2,u+l*3))t.Parent=workspace spawn(function()if o then o.VectorForce.Enabled=false end end)t.PrimaryPart:SetNetworkOwner(nil)DebrisService:AddItem(t,60)end end
-- @Context Server
-- Given a weapon definition, position, and direction. A throwable projectile will be simulated on all clients.
-- @param WeaponDefinition weaponDefinition
-- @param Vector3 position
-- @param Vector3 direction
-- @param Player _owner
function ProjectileReplication.ReplicateThrowable(weaponDefinition, position, direction, sendingPlayer)
	if RunService:IsServer() then
		local spawnedThrowableAsset = weaponDefinition:GetSpawnedThrowable()
		local clonedThrowable = spawnedThrowableAsset:Clone()

		-- Set the owner of this grenade for the combat api
		clonedThrowable:SetAttribute("OwnerID", sendingPlayer.UserId)

		local PrimaryPart = clonedThrowable.PrimaryPart

		-- Spawn the grenade infront of the player
		clonedThrowable:SetPrimaryPartCFrame(CFrame.new(position + direction * 2, position + direction * 3))

		clonedThrowable.Parent = workspace

		-- Disable velocity force the next frame
		spawn(function()
			if PrimaryPart then
				PrimaryPart.VectorForce.Enabled = false
			end
		end)

		-- Server owns the grenade.
		-- Don't want exploiters to teleport the grenade at creation.
		-- Or make a "Grenade shield" hack.
		clonedThrowable.PrimaryPart:SetNetworkOwner(nil)

		-- The throwable should destroy itself, but just in case we'll clean up after some time
		DebrisService:AddItem(clonedThrowable, 60)
	end
end
