Making spawn location enable if another spawn location isnt a certain team colour

I am trying to make a script that when a certain spawn location isn’t a certain team colour, another will be enabled. I don’t know the issue or what I have done, it’s probably something really simple but its not working.

local FF = script.parent.parent.parent.Flags

if FF.Flag1.SpawnLocation.TeamColor ~= "Crimson"  then
	script.parent.Enabled = true
end

Use BrickColor to find the TeamColor
Example:

if script.Parent.TeamColor == BrickColor.new("Bright green")then
	script.Parent.Enabled = false
end

Capture
Capture2

For you:

local FF = script.parent.parent.parent.Flags

if FF.Flag1.SpawnLocation.TeamColor == BrickColor.new("Crimson")then
	script.parent.Enabled = true
end
2 Likes

Surprised no one noticed this, but parent would be considered a unknown global variable (Or old & deprecated)

Lua is case-sensitive, so you’ll need to uppercase the Parent

local FF = script.Parent.Parent.Parent.Flags

if FF.Flag1.SpawnLocation.TeamColor ~= BrickColor.new("Crimson") then
    script.Parent.Enabled = true
end
1 Like

That hasn’t seemed to have worked for some reason. :thinking:

I tested it in a baseplate and it work so i dont know
Do you use a script to do it and not a local script ?
Did you checked in the explorer/properties in play mode to see if the spawn is enabled ?

Its not a local script, it’s a script. And it starts off disabled.

The entire script is just

if script.Parent.TeamColor == BrickColor.new("Bright green")then

script.Parent.Enabled = false

end

You should re read my old message, you apparently dont read everything.
This script was just an example you can do in a baseplate to test how it work.

if script.Parent.TeamColor == BrickColor.new("Bright green")then
	script.Parent.Enabled = false
end

The script for your game is here

local FF = script.parent.parent.parent.Flags

if FF.Flag1.SpawnLocation.TeamColor == BrickColor.new("Crimson")then
	script.parent.Enabled = true
end

I did change it to what it needs to be in my game. I was just using the thing you said as an example.

I have fixed it now, the problem was another script in my game was intervening with the spawn.