Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I script a regen button?

Asked by
Wolf8D 25
10 years ago

I want to be able to make a regen button that does not remove the model when regenerating a second time. This is a problem because whenever I use a vehicle with a regen and someone touches the regen, the vehicle that I was currently in disappears. What I mean is to duplicate a model without taking away another.

Thanks!

3 answers

Log in to vote
1
Answered by
nate890 495 Moderation Voter
10 years ago

Use this regenerate script:

local myModel = workspace.Vehicle
local button = script.Parent

local deb = false

myModel.Parent = nil --Hide your model, it still exists

button.Touched:connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if not deb and player then
        deb = true
        local newModel = myModel:clone()
        newModel.Parent = player.Character
        wait(5)
        deb = false
    end
end)

If you wanted to prevent vehicle clutter, you could put this script inside of the seat of your vehicle,

local seat = script.Parent
local car = seat.Parent --Taking a guess

seat.ChildRemoving:connect(function(child)
    if child:IsA("Weld") then
        car:Destroy()
    end
end)

In fact, I wouldn't even use my regenerate script and I would just use the one that Roblox uses for their vehicles in the old starter map (assuming that it doesn't exist anymore.) I can't find a uncopylocked version but if you search free models, I'm sure you'll find it.

Ad
Log in to vote
2
Answered by 10 years ago

Put the model in lighting and put in the following code:

model = game.Lighting.ItemName:Clone() -- replace "ItemName" with the model's name
model.Parent = game.Workspace
model.Position = Vector3.new(0,0,0) -- replace (0,0,0) with the position you want it to be placed at when it generates
2
The model should go in ServerStorage. User#11893 186 — 10y
1
Also note that Models do not have a Position property. Merely 2122 — 10y
1
That was my mistake, should've put MoveTo. FearMeIAmLag 1161 — 10y
Log in to vote
-1
Answered by 4 years ago

you wanted to go to heaven

Answer this question