I have made a car model, and I would like to respawn it when the car leaves its original location. I have a base part in the car which I want to be the part that is checked for when it leaves the invisible part at that location to mark where it is leaves.
I would like to do this rather than with a manual button press (which I already have). How could I modify my current script to allow for this? I have tried while loops but they cause lag when constantly running and I don't have much experience with the Touched event and GetTouchingParts().
Thanks :)
local button = script.Parent.Spawner
local model = script.Parent.Car
local backup = model:Clone()
local debounce = false
local model = script.Parent
local function onTouch(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil and debounce == false then
debounce = true
model = backup:Clone()
model.Parent = game.Workspace["Spawned Vehicles"]
model:MakeJoints()
wait(2)
debounce = false
end
end
button.Touched:connect(onTouch)

1 comment
Thank you so much man! I had no idea that TouchEnded existed. Thx :)