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

How would I make it so after a brick is touched the model regens?

Asked by
ned995 0
10 years ago

i have this already but i cant get it to regenerate after its removed

function onTouched(hit)
    local e = Instance.new("Explosion")
    e.BlastRadius = 300
    e.BlastPressure = 5000
    e.Parent = game.Workspace
    e.Position = script.Parent.Position
    wait(1)
    local Hint = Instance.new('Hint', Workspace)
    Hint.Text = "playername got pwnd"
    wait(2)
    Hint:Destroy()
    wait(.1)
    game.Workspace.bk:remove()

end
script.Parent.Touched:connect(onTouched)

3 answers

Log in to vote
0
Answered by
MrFlimsy 345 Moderation Voter
10 years ago

Instead of calling :remove() on the object you want to get rid of, set a variable to it and set it's parent to nil. When you want to bring it back, use the variable to set it's parent back to Workspace.

If the object gets destroyed in the explosion, you'll instead want to make a clone of the object and store it in ServerStorage. When you want to bring the object back, clone the object from ServerStorage and set it's parent to Workspace.

0
That's kind of what I did. He also made other mistakes in the script, so I did it for him. Shawnyg 4330 — 10y
Ad
Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

You made a few errors and left out some vital stuff. For the touched event, you have to check if it's a player. Or else, a random brick could hit it and it would explode.

script.Parent.Touched:connect(function(hit)
    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
        p = game.Players:GetPlayerFromCharacter(hit.Parent)
        aa = script.Parent:clone()
        aa.Parent = game.Lighting
        aa.Name = "Clone"
        local e = Instance.new("Explosion")
        e.BlastRadius = 300
        e.BlastPressure = 5000
        e.Parent = script.Parent
        e.Position = script.Parent.Position
        wait(1)
        local Hint = Instance.new('Hint', Workspace)
        Hint.Text = p.Name.." got pwnd"
        wait(2)
        Hint:Destroy()
        wait(.1)
        aa.Parent = Workspace
        --game.Workspace.bk:remove()
        --I'm not sure if the above is necessary. If it is, just remove the '--'
    end
end)
Log in to vote
-1
Answered by 10 years ago

-- Made by BuildingAustin

model = game.Workspace.Brick -- First you change "coolironman"coolironman" (It can't have spaces) backup = model:clone()

function onChatted(msg, recipient, speaker)

local source = string.lower(speaker.Name) msg = string.lower(msg)

if (msg == "titanic") then -- change "Iron man regen" to what ever you want to say to regenerate a model. model:remove() model = backup:clone() model.Parent = game.Workspace model:makeJoints() end

end

function onPlayerEntered(newPlayer) newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) end

game.Players.ChildAdded:connect(onPlayerEntered)

Try this it works better!

0
This is no where close to what he wanted... Shawnyg 4330 — 10y
0
Its a Voice thing BuildingAustin 0 — 10y
0
He wanted it where when it explodes, it auto-regenerates. Shawnyg 4330 — 10y

Answer this question