(Sorry for my english i’m using google translator)
Hello, i’m working on a projectile that fires when mouse is pressed and i made a script to when it dectets that a part touched it and the part isn’t part of a character the script creates a motor6d that connects the projectile and the part that touched it, and worked but the projectile orientation was not as before, when it was fired, then i searched a bit in devforum and in the roblox api and the solution i found was changing the C0 to the old projectile CFrame (before it get touched) but the part teleports to a random position that i can’t see where.
Without setting the C0 the part still teleports to a random position, but it’s just sometimes.
How can i keep the part orientation when i create the motor6d? There is a better way of keeping the projectile CFrame?
Setting C0:
Without setting it:
Code:
if Debounce and Comparar(Touch, false, NotParts) and Touch.CanCollide then -- Is not part of a character
Debounce = false
if script.Parent:FindFirstChild("BodyVelocity") then
script.Parent.BodyVelocity.Velocity = Vector3.new(0, 0, 0)
script.Parent.BodyVelocity.Parent = nil
end
local Motor6d = Instance.new("Motor6D")
Motor6d.C0 = script.Parent.CFrame -- sets C0
Motor6d.Parent = script.Parent
Motor6d.Part0 = script.Parent
Motor6d.Part1 = Touch
wait(5)
script.Parent.Parent = nil
end