Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How come this brick isn't regening properly?

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 comment

1

on line 19 you set brick to game.workspace

1 answer

✓ Accepted answer

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

Change line 13 to

if brick.Parent ~= workspace then

This discussion is preserved as it was. New answers, comments, and votes are closed.