Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Team Flag Script Not Working. Always printing the error code i made?

Hello, i am having a problem with this script, it is a script to pick up a flag and lower a value, but that is not a problem, it is a function to stop the same team from picking up their own flag. It always prints invalid (that i have put to check), even if i am in the opposite team.

Here's the code:

function checkplayer(hit)
	local player = players:GetPlayerFromCharacter(hit.Parent)
	local playername = hit.Parent.Name
	local human = hit.Parent:FindFirstChild("Humanoid")
	if  human then
	if not players[playername].TeamColor == BrickColor.new("Bright blue") then
	ontouchorremove()
	print("valid")
	else
		print("invalid")
	end	
	end
	end

	script.Parent.Touched:Connect(checkplayer)

4 comments

0

I think you could swap BrickColor.new("Bright blue") for just == "Bright blue" and make sure everything was wrote right

0

i already did that

0

...And?

0

nope, still the same

1 answer

I have recently updated the script, no worry's. I changed the 6th line to a if then statement instead than a if not then statement. Also, i had to add a argument for calling my other function.

function checkplayer(part)
	local playername = part.Parent.Name
	local human = part.Parent:FindFirstChild("Humanoid")
	
	if  players[playername].TeamColor == BrickColor.new("Bright red") then

	ontouchorremove(part)
	print("valid")
	else
		print("invalid")
	end	
	end

	script.Parent.Touched:Connect(checkplayer)

This discussion is preserved as it was. New answers, comments, and votes are closed.