I am making a throwable knife and in my script I anchor the knife and then on every renderstepped I move the knife a little in the direction of the throw.
I want to get the knife to rotate while it is in the air.
The problem is that normal scripts don’t work and my knife goes crazy when I try to rotate it in my script.
Here is the code:
local Loop
local pos = getMousePos()
Loop = game:GetService("RunService").RenderStepped:Connect(function(dt)
throwknife.CFrame = CFrame.new(throwknife.Position + throwknife.CFrame.lookVector, pos)
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Blacklist
rayParams.FilterDescendantsInstances = {tool, player.Character or player.CharacterAdded:Wait()}
local raycast = workspace:Raycast(throwknife.Position, throwknife.CFrame.lookVector, rayParams)
if raycast then
local hit = raycast.Instance
local normal = raycast.Normal
local pos = raycast.Position
print(hit.Name)
Loop:Disconnect()
end
end)
As post above says you need to replace look vector with mouse position at raycast and with multipling on rotated CFrame with minimal position at setting new CFrame