I’m aware there’s other posts similar to this, but none of which help me. After a lot of trial and error, and stealing code (which I’m not proud of), this is my last hope. What I’m working on is knife throwing, like any other Jjba game. Should I use velocity or tween, and how would I go about that?
I’ve gotten to the point where it can damage, but most of the time it gets destroyed before it hits, and I think the solution to that is to move it a bit further, but I don’t know how. Also, I don’t know how to make it face the direction it’s moving in. I’m using TweenService.
local knife = script.Knife:Clone()
local mouse = args[1]
knife.Parent = game.Workspace
knife.Position = player.Character.HumanoidRootPart.Position
--knife.CFrame = CFrame.new(knife.Position, mouse.Position)
--knife.CFrame = CFrame.lookAt(knife.Position, mouse.Position)
local destroyed = false
local movement = TS:Create(knife, TweenInfo.new((knife.Position - mouse.Position).Magnitude / 60), {Position = mouse.Position})
if game.Workspace:FindFirstChild("TSEffect") == nil then
movement:Play()
knife.CFrame = CFrame.new(knife.Position, mouse.Position)
print((knife.Position - mouse.Position).Magnitude / 60)
knife.Touched:Connect(function(hit)
if hit.Parent.Name ~= player.Name then
if hit.Parent:FindFirstChild("Humanoid") and destroyed == false then
hit.Parent.Humanoid.Health -= 5
knife.Sound:Play()
end
destroyed = true
task.wait(0.2)
knife:Destroy()
end
end)
else
movement:Pause()
end