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: