Why wont this work

Hello! im trying to get this system to turn the bgcolor of the template to green if the value == 1. But it wont work! please help there are no errors

local ZoneWalls = workspace:WaitForChild("Areas"):GetChildren()
local Player = game:GetService("Players").LocalPlayer

local PlayersAreas = Player:WaitForChild("Areas"):GetChildren() 

task.wait(1)

for _, area in PlayersAreas do
	local Template = script._Template:Clone()
	Template.Name = area.Name
	Template.ZoneName.Text = area.Name
	Template.Parent = script.Parent:WaitForChild("Container")
		if area:IsA("BoolValue") then
			if area.Value == 1 then
				Template.BackgroundColor = Color3.fromRGB(85,255,0)
			end
		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

Are you sure BackgroundColor shouldn’t be BackgroundColor3.
Also really don’t like to see a bool used like that. I’m sure it works but uggg.

2 Likes

Is this script set to run continuously to check if players are in the PlayersAreas? As it is it only runs once.

I don’t see a function to perform this check if players have left or entered the area.
A while true do loop could work, but it takes more work for the engine to keep checking that.

A bool value only stores true and false. I assume that you meant to do true.

local ZoneWalls = workspace:WaitForChild("Areas"):GetChildren()
local Player = game:GetService("Players").LocalPlayer

local PlayersAreas = Player:WaitForChild("Areas"):GetChildren() 

task.wait(1)

for _, area in PlayersAreas do
	local Template = script._Template:Clone()
	Template.Name = area.Name
	Template.ZoneName.Text = area.Name
	Template.Parent = script.Parent:WaitForChild("Container")
		if area:IsA("BoolValue") then
			if area.Value == true then
				Template.BackgroundColor = Color3.fromRGB(85,255,0)
			end
		end
	end

I think you meant to do this

2 Likes

Thanks lol! i’m new to scripting so i forget these things :slight_smile:

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