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
on line 19 you set brick to game.workspace