Script not Enabling but Saying it is

I want this script to be enabled whenever it is put into workspace.
The issue is, it’s not enabling at all but when I print the enabled property it says it is.

while true do wait(ChangeTypeTick)
	local CurrentType = ZombieType.Value
	--ZombieType.Value = Types[math.random(1,#Types)].Name
	ZombieType.Value = "Void"
	local Folder = TerrainTypes[ZombieType.Value]
		
	local GrassColor = Folder:WaitForChild("GrassColor").Value
	workspace.Terrain:SetMaterialColor(Enum.Material.Grass, Color3.new(GrassColor))
		
	if Folder:FindFirstChild("Boss") then
		local Boss = Bosses:FindFirstChild(ZombieType.Value)
		local BossClone = Boss:Clone()
		local ControlClone = ZombieControlScript:Clone()
			
		BossClone:Clone().Parent = workspace
		ControlClone.Parent = BossClone
		ControlClone.Enabled = true
	end
end

How exactly are you enabling it?

Also:

If this Value is a Color3, Just Apply it as such:

workspace.Terrain:SetMaterialColor(Enum.Material.Grass, GrassColor)

It’s enabled by:

ControlClone.Enabled = true

Two things:

  • Is it a local script or a server script?
  • Is it enabled by default before you enable it directly?

Both are server scripts and it’s disabled by default.

Though, One Question,
Why dont you Control the Zombies all Together instead of Separately?
Instead of having One Script per Zombie, you can have one Script for all, Which is Simple to make.

Does it throw an error when enabled? And which service is it a descendant of when enabled?

Referring to @DasKairo’s suggestion, you can use the CollectionService.

1 Like

That’s a really good point, I’ll try that.

It doesn’t throw any errors. What do you mean by which service?

Workspace, ReplicatedStorage, Lighting, etc. I’m assuming it’s workspace, but you can never be too sure.
Edit: nvm, it’s in the code. Workspace it is

Oh, I read it wrong, it’s workspace.

Try setting enabled to false directly before setting it to true…

The script is still disabled in the explorer.

I mean via code. Like this:

	local CurrentType = ZombieType.Value
	--ZombieType.Value = Types[math.random(1,#Types)].Name
	ZombieType.Value = "Void"
	local Folder = TerrainTypes[ZombieType.Value]
		
	local GrassColor = Folder:WaitForChild("GrassColor").Value
	workspace.Terrain:SetMaterialColor(Enum.Material.Grass, Color3.new(GrassColor))
		
	if Folder:FindFirstChild("Boss") then
		local Boss = Bosses:FindFirstChild(ZombieType.Value)
		local BossClone = Boss:Clone()
		local ControlClone = ZombieControlScript:Clone()
			
		BossClone:Clone().Parent = workspace
		ControlClone.Parent = BossClone
		ControlClone.Enabled = false
		ControlClone.Enabled = true
	end
end

@DasKairo solution worked, thanks for the help.

1 Like

Please set the post as a solution if it was helpful.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.