Script seems to work in studio but bugs out in game

So I’ve made 100 different versions of this script and it just glitches out each time, sometimes it works sometimes it doesnt. Most of the time it works in studio most of the time it breaks in game.

it’s supposed to teleport the car to the other lane, turn it around and keep the velocity.

local TP1 = script.Parent.TeleportStart
local pos = CFrame.new(Vector3.new(script.Parent.WantedPos.Position)) * CFrame.Angles(0, math.rad(180), 0)

local debounce = true

TP1.Touched:Connect(function(hit)

	if debounce == true and hit.Name == "DriveSeat" then
		debounce = false

		local Porsche = hit.Parent
		Porsche.PrimaryPart = hit
		Porsche:PivotTo(pos)

		for i, v in pairs(Porsche:GetDescendants()) do
			if v.Name == "DriveSeat" or v:IsA("BasePart") or v:IsA("MeshPart") then
				v.Velocity = v.Velocity * Vector3.new(-1, 1, -1)
			end
		end

		wait(5)
		debounce = true

	end
end)

dont change the primary part

maybe try AssemblyLinearVelocity or ApplyImpulse()

I’m not changing it just making sure its set, I’ve tried both assemblylinearvelocity, linearvelocity and applyimpulse and none have worked at all.

i think you must have a “root” part of the car, that all other parts are weld to.
try only set that root part AssemblyLinearVelocity

The driveseat is the rootpart, I can’t change its assemblylinearvelocity because its the primarypart of the car.

i can change it no problem.
be sure if the car is controlled by server side or client side,
and then you need to change its velocity by the same side

I fixed by making it teleport in a localscript

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.