A regen button for a car

Hey everyone! So I wanted to make a regen button for a car but didnt know how to do it so here I am asking the dev forum how to do it. Ill be greatful if someone actually gives me a tutorial or a basic tutorial on how to do it.

1 Like

What do you mean by regen button, like adding health to the car or respawning a car?

So, have a ClickDetector in a part in the workspace. In ReplicatedStorage have a model called Car (this is the car model)

Then in the click detector all you need is a simple script.

local RS = game:GetService("ReplicatedStorage")
local car = RS.Car
script.Parent.MouseClick:Connect(function()
    if game.Workspace:FindFirstChild("Car") then game.Workspace:FindFirstChild("Car"):Destroy() end
    local clone = car:Clone()
    clone.Parent = game.Workspace
    clone.Position = script.Parent.Parent.Position + Vector3.new(10,0,0)
end)

This script listens for clicks on the part, then destroys the car that’s currently in the game (if there is one) and finally cloning the car from replicated storage to the workspace and setting it’s position

2 Likes