Snowball System Lag

So I’m helping someone make a snowball system for some Robux, however he pointed out something noticeable. He said that the snowball upon being thrown stays still for a large fraction of a second before moving as intended. Here is a video to show what I mean:

robloxapp-20231217-0548365.wmv (450.7 KB)

Here’s my code for what’s going on if it helps. (Note that the remoteevent is being fired everytime the snowball tool is activated)

game:GetService("ReplicatedStorage").SnowballRemoteEvent.OnServerEvent:Connect(function(player, startingPosition, direction)
	local snowballClone = game:GetService("ServerStorage").Snowball:Clone()
	snowballClone.Parent = workspace
	snowballClone.PlayerValue.Value = player
	snowballClone.Position = startingPosition
	snowballClone.CFrame = CFrame.lookAt(snowballClone.Position, direction)
	snowballClone.SnowballLinearVelocity.LineDirection = snowballClone.CFrame.LookVector
end)

I had some ideas on what could be causing this but I’m out of ideas to fix this and he needs this done soon which is why I’m here. Any ideas are appreciated. Thanks.

Most likely the issue is because of network ownership, doing this:

game:GetService("ReplicatedStorage").SnowballRemoteEvent.OnServerEvent:Connect(function(player, startingPosition, direction)
	local snowballClone = game:GetService("ServerStorage").Snowball:Clone()
	snowballClone.Parent = workspace
	snowballClone.PlayerValue.Value = player
	snowballClone.Position = startingPosition
	snowballClone.CFrame = CFrame.lookAt(snowballClone.Position, direction)
	snowballClone.SnowballLinearVelocity.LineDirection = snowballClone.CFrame.LookVector
	snowballClone:SetNetworkOwner(player)
end)

should solve the problem

2 Likes

snowballClone.Parent = workspace – put it last in the script
try this

game:GetService("ReplicatedStorage").SnowballRemoteEvent.OnServerEvent:Connect(function(player, startingPosition, direction)
	local snowballClone = game:GetService("ServerStorage").Snowball:Clone()
	snowballClone.PlayerValue.Value = player
	snowballClone.Position = startingPosition
	snowballClone.CFrame = CFrame.lookAt(snowballClone.Position, direction)
	snowballClone.SnowballLinearVelocity.LineDirection = snowballClone.CFrame.LookVector
    snowballClone.Parent = workspace
end)
1 Like

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