Objects Freeze Before Launching!

I have a projectile launcher stuff, it’s working perfectly but sometimes it doesnt.

like sometimes it move immediatley after appear on workspace and velocity, but sometimes it freezes for a miliseconds and after that it moves.

is there a way to make it moves immediatley and never freezes??

Server code :

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")

local Projectiles = require(ReplicatedStorage.Projectiles)

ReplicatedStorage.throwProjectile.OnServerEvent:Connect(function(Player, ...)
	local args = { ... }

	local projectileName = args[1]
	local mousePosition = args[2]
	local Character = Player.Character

	if not projectileName or (not ReplicatedStorage.Projectiles:FindFirstChild(projectileName) or not Projectiles[projectileName]) or not mousePosition or not Character then  return end
	local Origin = Character.PrimaryPart:GetPivot() * Vector3.new(0, 0, -2)
	local Velocity = (mousePosition - Origin).Unit * Projectiles[projectileName].Speed

	local projectile = ReplicatedStorage.Projectiles[projectileName]:Clone()
	projectile:PivotTo(CFrame.new(Origin))
	projectile.Parent = game.Workspace
	
	if projectile:IsA("BasePart") then
		projectile.Velocity = Velocity
		projectile.CanCollide = true
	elseif projectile:IsA("Model") then
		projectile.PrimaryPart.Velocity = Velocity
		for _, Object in pairs(projectile:GetDescendants()) do
			if not Object:IsA("BasePart") then continue end
			Object.CanCollide = true
		end
	end
	
	task.delay(5, function() 
		projectile:Destroy() 
	end)
end)

Gyazo video

Set Network Ownership of the Object to the Player who is throwing the Projectile using :SetNetworkOwner(), use nil if you want to apply it to the Server, or Specify a Player.

Network Ownership is Automatically Applied between the Server, and Players, which is why you usually see these delays, keeping it under one owner would prevent this.

Yooo thank u bro, it fixed it but does it affect another player than see it/touch it, i set the Network Owner to player than launched it?? thank you again broo

It should be affected by other players, all it really does is tell who owns the Objects, and how to Apply Physics.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.