Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Making throwing knives using lerp?

Asked by 4 years ago

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

Log in to vote
1
Answered by
iHavoc101 127
4 years ago

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)
Ad

Answer this question