How do I change a model's position with LUA? Is this even possible?

So, I’m once again having issues learning simple scripting. And I feel that getting help from Forums would be better than not being able to overcome future issues on projects. So, I’m working on a simple code that should teleport cars to a certain position using X Y and Z coordinates. I’ve got a code written already, but it doesn’t seem to work once the vehicle I’m seated in collides with the part this script it in. I’m not sure if it has to do with the player being inside the vehicle either, that could cause complications as well because, I’m not entirely sure. Any tips or solutions?

function onTouch(hit)
if hit.Name == "Car" then 
		hit.Car:PivotTo(currentPivot * CFrame.new(0, 90, -10))
end
end

script.Parent.Touched:connect(onTouch)

you can do something like this:

local touchPart = workspace.TouchPart -- Change this to your touch part!
local debounce = false -- Set a cooldown value

touchPart.Touched:Connect(function(hit)
  if debounce then return end -- If its on cooldown, don't run the code after this
  
  debounce = true -- Set cooldown to true

  if hit.Name == "Car" then
    hit:PivotTo(currentPivot * CFrame.new(0, 90, -10)) -- Change pos if the car touches the part
  end

  task.delay(1, function()
    debounce = false --Remove cooldown after 1 second
  end)

end)
1 Like