Why Does This Throwing Star Look Laggy?

So when you activate the tool(throwing star), it is supposed to throw in the direction. It does that… but it looks laggy;-;. Does anybody know how I can fix this?? Thanks!
Heres The Code:

local DebrisService = game.Debris
local Tool = script.Parent
local SendMouseInformationEvent = Tool.SendMouseInformation
local ThrowingStar = Tool.Handle
local Speed = 100
local StarRot = 50
local StarDamage = 20
function OnMouseActivate_EventFunction(Player, VectorMousePoint)
	if not Player or not VectorMousePoint then return end
	local ThrowingStarClone = ThrowingStar:Clone()
	ThrowingStarClone.Parent = workspace.GearStorage
	ThrowingStarClone.CanCollide = true
	ThrowingStarClone.CFrame = CFrame.new(ThrowingStarClone.Position, VectorMousePoint)
	ThrowingStarClone.Velocity = ThrowingStarClone.CFrame.LookVector * Speed
	local BodyAngularVelocity = Instance.new("BodyAngularVelocity")
	BodyAngularVelocity.MaxTorque = Vector3.new(4000, 4000, 4000)
	BodyAngularVelocity.P = 1250
	BodyAngularVelocity.AngularVelocity = Vector3.new(StarRot, 0, 0)
	 BodyAngularVelocity.Parent = ThrowingStarClone
	local function OnThrowingStarTouchedFunction(TouchedObject)
		if TouchedObject.Parent == workspace.GearStorage then return end
		if TouchedObject.Parent == Tool.Parent then return end
		if TouchedObject.Name == ThrowingStar.Name then return end
		local WeldContraint = Instance.new("WeldConstraint")
		WeldContraint.Parent = ThrowingStarClone
		WeldContraint.Part0 = ThrowingStarClone
		WeldContraint.Part1 = TouchedObject
		ThrowingStarClone.Anchored = true
		ThrowingStarClone.Velocity = Vector3.new(0, 0, 0)
		ThrowingStarClone.Anchored = false
		if TouchedObject:FindFirstChild("Humanoid") then
			local Humanoid = TouchedObject.Humanoid
			Humanoid:TakeDamage(StarDamage)
		end
		DebrisService:AddItem(ThrowingStarClone, 5)
		
		
	end
	ThrowingStarClone.Touched:Connect(OnThrowingStarTouchedFunction)
end
SendMouseInformationEvent.OnServerEvent:Connect(OnMouseActivate_EventFunction)

Here’s the vid:

Throw the whole code away. From what i see that is such an un-optimized code it hurts to read. Your far better off tweening the star from its original position to the hit position. And you’re doing so many if statements its gotta stop and calculate before it continues on possibly adding that laggy feeling

3 Likes

maybe it has something to do with network ownership? Network Ownership | Documentation - Roblox Creator Hub

1 Like

First Off I’m going to need the real velocity, this way it actually looks like a real throwing star, with tweening, yes it will look smooth, but you can’t as easily get it to look like it’s falling. The If statements? Those are useful because the first one makes sure it won’t error, the ones in the touched event are used to make sure its not hitting the owners character or a clone of its self, but still thanks for the advice

It may actually have something to do with that because, in the problem section of the article,
it states that there might be a hop when they switch ownership.


This will probably fix it thanks.

1 Like

Your checking for reasons they aren’t allowed into the party. Not checking for reasons they should be. That is bad practice. I understand why they are there but the execution, again, is bad practice. Instead of checking on why they SHOULDN’T be let into the party, check why they SHOULD be.