Script doesnt work, but theres no error 3

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    A decay script for when a brick is unanchored, it decays and destroys itself.
  2. What is the issue? Include screenshots / videos if possible!
    It doesnt appear to work, but no errors are present.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    None, yes, found nothing.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that itā€™s easier for people to help you!
    I use a second script called ā€œSetupā€ in the workspace to clone the decay script to bricks.
    Setup script:
while true do
	local brick=workspace:WaitForChild("Brick")
	local ss=game:GetService("ServerStorage")
	local clone=ss.Decay:Clone()
	workspace:WaitForChild("Brick")
	clone.Parent=brick
	task.wait(0.02)
end

Decay script:

if script.Parent.Name=="Brick" then --check
	if script.Parent.Anchored==false then --check 2
		task.wait(10)
		script.Parent.Material=Enum.Material.CorrodedMetal
		task.wait(2)
		script.Parent:Destroy()
	end
end

Please do not ask people to write entire scripts or design entire systems for you. If you canā€™t answer the three questions above, you should probably pick a different category.

1 Like

I am having literally the same issue and canā€™t find a solution!

1 Like

Itā€™s possible that the script starts before you clone it into the brick, skipping the decay part because script.Parent.Name ~= "Brick". You could do two things to fix this:

The first thing is to enable the script once you parent it to the brick. Set the scriptā€™s enabled property to false in the explorer. Then, in your first script after setting the cloneā€™s parent to brick, you set the scripts enabled property to true like clone.Enabled = true.

The second thing you can do is to detect changes that fire when the brick is reparented or unanchored using connections. Although, I am not sure what exactly you want to detect here so I canā€™t give one example for this case.

Completely fixed this already. Change the decay script run context from legacy to server and it works.

What do you mean by that? Huhh???

An error, finally! ā€œServerStorage.Decay:1: attempt to index nil with ā€˜Nameā€™ā€

1 Like
local brick=workspace:WaitForChild("Brick")
local ss=game:GetService("ServerStorage")
local clone=ss.Decay:Clone()
workspace:WaitForChild("Brick")
clone.Parent=brick

change the setup to this. No reason to loop anything

I dont think its working, ive been watching an unanchored part for a bitā€¦ And it does not decay.

Yeah idk what you did man iā€™m sorry I know how real the struggle is sometimes with this stuff im just guna send you the file and you do what you want with it, it does exactly what you guys are trying to do

Ill can send you the place file if you want.
It can help alot.

Solved The Problem.rbxl (53.2 KB)

Open this and watch the part. You will see it do exactly what you are trying to do

Post cleared cuz NO ONE STEALS MY GAEM!!! >:P

Nobody can steal it anyways, no worries. Assets are all private. Iā€™ll return it fixed

No its not fixed, i used print() to debug, and it doesnt appear.

1 Like

Just please return the fixed file.

1 Like

I am give me a few minutes this is a little more to do than what I was doing originally

Oh btw, its not fixed yet. I tried, and it doesnt seem to delete. I put a print() to test it and it doesnt appear.

Fixed Your Game.rbxl (166.0 KB)

Please try and be patient when someone is fixing your game instead of flooding the thread. I am not even supposed to be handing you scripts without you understanding how they workā€¦ I did this out of kindness. I hope youā€™re happy with it!

You were only deleting them when they are unanchored, and most of the parts are anchored. Wasnā€™t hard to fix