Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Making throwing knives using lerp?

So recently ive found out about :lerp() and ive tried to make throwing knives, now this is just a test script but the knives instantly arrive at the mouse

local event = game.ReplicatedStorage.Firetest
event.OnServerEvent:Connect(function(plr,mouse,mousehit)
	local part = Instance.new("Part",workspace)
	part.Size = Vector3.new(1,1,1)
	part.Material = Enum.Material.Foil
	part.CanCollide = true
	part.Anchored = false
	
	
	for i=0,1,0.001 do
 wait()
 part.CFrame = mousehit:lerp(mousehit,3)
end
end)

Im also using remotes this is the server scrips, the localscript just activates when a tool is activated.

Is there a way to slow down lerp? Thanks for help :)

1 answer

✓ Accepted answer

alright, uhh, don't use lerp use tweenservice?

local event = game.ReplicatedStorage.Firetest
event.OnServerEvent:Connect(function(plr,mouse,mousehit)
    local part = Instance.new("Part",workspace)
    part.Size = Vector3.new(1,1,1)
    part.Material = Enum.Material.Foil
    part.CanCollide = true
    part.Anchored = false
    game:GetService('TweenService'):Create(part, TweenInfo.new(1), {Position = mousehit.Position}):Play()

end)

This discussion is preserved as it was. New answers, comments, and votes are closed.