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

How come this brick isn't regening?

I made a script where a brick falls when touched and regenerates after 3 seconds

-------------------------------------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
		wait (3)
		brick.Anchored = true
		fallen = false
	end
end)

----------------------------------regen-----------------------------------------

script.Parent.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)

It falls fine, but it keeps saying "The Parent property of Workspace is locked" in the output and it doesn't regen. Could it be it being anchored again after falling?

Script is inside the brick

1 answer

Here is a refined version

local fall = false
function Create()
local part = 'Part'
local brick = Instance.new(part, workspace)
brick.Anchored = true
brick.CFrame = brick.CFrame + Vector3.new(0,5,0)
end

brick.Touched:connect(function(hit)
if game.Players[hit.Parent.Name]~=nil and not fall then
fall = true
brick.Anchored = false
wait(3)
fall = false
end
end)

brick.Changed:connect(function(C)
if C == 'Anchored' then
C:Destroy()
wait(1)
Create()
else
warn('Why did you change my properties without my consent D:')
end
end)

2 comments

0

Can you please explain what was changed and what I did wrong?

0

Plus this doesn't work

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