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

How come this brick isn't regening properly?

Asked by 8 years ago

I wrote a script so a part can fall once a player touches it and regenerate after a short time. The script is a regular script and is located inside a part. It falls just fine, but when it comes to the regen function it does nothing an "The Parent property of Workspace is locked" is displayed in the output.

THE SCRIPT

-------------------------------------short cuts----------------------------------
local fallen = false
local brick = script.Parent
-------------------------------------the fall-------------------------------------
brick.Touched:connect(function(part)
    if part.Parent:FindFirstChild("Humanoid") and not fallen then
        fallen = true
        brick.Anchored = false
    end
end)
----------------------------------regen-----------------------------------------
brick.Changed:connect(function(part)
    if brick ~= workspace then
        local backup = brick:Clone()
        while true do
            wait (3)
            brick:Destroy()
            brick = backup:Clone()
            brick = game.Workspace
            brick:makeJoints()
        end
    else
        error("Nothing happened!")
    end
end)
1
on line 19 you set brick to game.workspace User#5423 17 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

The brick cannot be the workspace, but it can be a child of it.

Change line 13 to

if brick.Parent ~= workspace then
Ad

Answer this question