I am making a regenerating race car when I step on a brick, however when the car's seat is at the same place as it was when you regen it, it deletes the car then spawns a new one. Thanks to Ki11aRoboTech for the regen button. The problem is, when I step on the button (it used to work when I didn't edit the code) it does nothing, no matter what. Code:
--Made by Ki11aRoboTech, just group with the model to get it to work. This button also works for planes.
--Do not change anything besides the lines mentioned below.Again,Group it to anything you want(Cars,Trains,Planes Etc.)
model = script.Parent.Parent--Indicates that the script interacts with the model the button is grouped with.
messageText = ""--If you want a message to appear upon pressing, type it here.
message = Instance.new("Message")
message.Text = messageText
backup = model:clone()
enabled = true
function regenerate()
message.Parent = game.Workspace
-- Part I edited
if model.VehicleSeat.Position.X == -161 and
model.VehicleSeat.Position.Y == 11.5 and
model.VehicleSeat.Position.Z == 159 then
model:remove()
wait(3)--Change this number to display the regen message as long as you want in seconds.
model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()
message.Parent = nil
script.Disabled = true
script.Parent.BrickColor = BrickColor.new(26)--Black
wait(5)--Change this number to change the time in between regenerations via the button, in seconds..
script.Parent.BrickColor = BrickColor.new(104)--Purple
script.Disabled = false
end
function onHit(hit)
if (hit.Parent:FindFirstChild("Humanoid") ~= nil) and enabled then
regenerate()
end
end
end
wait(3)--Change this number to display the regen message as long as you want in seconds.
model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()
message.Parent = nil
script.Disabled = true
script.Parent.BrickColor = BrickColor.new(26)--Black
wait(5)--Change this number to change the time in between regenerations via the button, in seconds..
script.Parent.BrickColor = BrickColor.new(104)--Purple
script.Disabled = false
end
function onHit(hit)
if (hit.Parent:FindFirstChild("Humanoid") ~= nil) and enabled then
regenerate()
end
script.Parent.Touched:connect(onHit)
--Remember To read EVERYTHING on this button that includes the top >_> Edit it only for Pros.
Done.

2 comments
Why would you want to remove the model if its in that position? (15-18)
you know how when you play a game then there is a car regenerator. If a car is in the spot where it normally spawns, spawning another car will make a car INSIDE of the existing car, thus making the car unusable.