Script stop working on cloned part

Im trying to color a cube into a Black. It works on a first cycle of clone but on the second cylce of cloning the script for color stop working.

---- Server Script

local Part = game. ServerStorage.Part
While true do
wait(1)
local Part_Clone = Part:Clone()
Part_Clone.Name = "Cube"
Part_Clone.Parent = game.Workspace
wait(10)
Part_Clone:Destroy()
end

---- Separate Server Script

local Cube = 
game.Workspace:WaitForChild("Cube")
cube.BrickColor = BrickColor.new("Black")

1 Like

There’s a capital w put it lower case.

Your separate server script is only running one time, its not in any while true do loop

Why not just change the color of the cube when you clone it?

local part = game.ServerStorage.YourPart

Part_Clone = part:Clone()
Part_Clone.Color = Color3.new()

I intentionaly do that for a purpose. The script for a color are just intended to test if the script work

Sorry but a manually write the code since im on my Phone earlier

If you have multiple parts named the same way the game is just gonna pick one and only update that single one.

Make the game copy the parts into a folder and then run a for loop through all instances in that folder.

Also why do you need to use Two diffrient server scripts for this? You can do it all in one script.

But on my seperate server script on the first line of the script, the code will try to wait and find if there is Cube available on the workspace.

It stands as a Main script and a script specific for a cube only. Becuase its to messy to add it at ones.

That’s unreasonable.

If you want to do this just do it in one script like this:


function CubeColor()
      for i, v in --[["Folder Name Here"]]:GetChildren() do
             v.Color = Color3.FromRGB(0,0,0)
      end
end

local Part = game. ServerStorage.Part
While true do
wait(1)
local Part_Clone = Part:Clone()
Part_Clone.Name = "Cube"
Part_Clone.Parent = game.Workspace.--{["Folder Name Here"]]
CubeColor()
wait(10)
Part_Clone:Destroy()
end
1 Like

No, just only one of it. Would you to try the code that i had posted?

Why do you only want to change one random object, I don’t see the problem your facing at all.

If you just want to change the color of a single part that’s created and then destroyed then change the color directly in the script that creates that part.

local Part = game. ServerStorage.Part
While true do
wait(1)
local Part_Clone = Part:Clone()
Part_Clone.Name = "Cube"
Part_Clone.Parent = game.Workspace
Part_Clone.Color = Color3.FromRGB(0,0,0)
wait(10)
Part_Clone:Destroy()
end
1 Like

If you found a solution, please mark it.

I really appreciate your effort but the script i posted was a just a basic concept. But could you just answer my first top question?

I ended up putting color script into a While loop. Get rid of the problem

1 Like