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

Respawn button issues, how to make a car respawn without destroying?

Asked by 5 years ago

I Am Trying To Make A Car That When You Press The Respawn Button It Keeps The Car And Respawns It. Currently I Am Struggling With The Button Respawning

model = script.Parent.Parent
messageText = ""re.

message = Instance.new("Message")
message.Text = messageText
backup = model:clone()
enabled = true

function regenerate()

    wait(3)

    model = backup:clone()
    model.Parent = game.Workspace
    model:makeJoints()
    message.Parent = nil

    script.Disabled = true
    script.Parent.BrickColor = BrickColor.new(26)--Black
    wait(5)
    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

script.Parent.Touched:connect(onHit)

1 answer

Log in to vote
1
Answered by
mc3334 649 Moderation Voter
5 years ago

To make a car spawn when a brick is touched, you can do something as simple as the following:

brick = --Instance of part that gets touched here
car = --Instance of the model you want to duplicate(I suggest putting it where you want it to spawn, then putting it in server storage and getting it from there)

db = false
brick.Touched:Connect(function()
    if db == true then return end
    db = true
    car:Clone()
    wait(10)
    db = false
end)

That can be in a server script anywhere. With further questions/comments/concerns, feel free to reply to my answer. I hope I was able to help! ~mc3334

Ad

Answer this question