Script problem with teams

So i got a script of some arresting system for my game, and to prevent abuses between players, the script itself came with a team anti-abuse kind of thing. But i can’t figure it out to set it up, because im a nooby on this type of things.

	script.Parent.TextLabel.Text = target
	script.Parent.targ.Value = target
	script.Parent.Visible = true


	if game.Players:FindFirstChild(target).Team.BrickColor == 'Shamrock'
	script.Parent.TextLabel.Text = ''  -- it labels "script".Parent.TextLabel.Text =
	script.Parent.targ.Value = ''
	script.Parent.Visible = false

end) -- and this.

There are a few things to do here.

It appears you are missing the “then” and “end” words in your if statement. Here’s an example of what you should do:

    if 1 == 1 then -- Note the "then" here
    end -- This "end" closes the if statement
end) -- This "end" wraps up what happens when the touched event is fired.

If “Shamrock” is the BrickColor of the player using the arrest system, then change == (meaning equal to) to ~= (meaning not equal to). Between the if and end, put else. Now,

if game.Players:FindFirstChild(target).Team.BrickColor ~= 'Shamrock' then
    -- put the code for that will happen if the target is not on the shamrock colored team here
    -- if the target is on the shamrock colored team, then code placed here will run instead

I wrote this in kind of a hurry, so I’ll explain more if needed.

So my point is that the brick color of Shamrock cannot arrest themselves because they are the police, and also, if i put more teams it should be like ‘Shamrock, Black, etc’?

It should be

if game.Players:FindFirstChild(target).Team.BrickColor == 'Shamrock' or game.Players:FindFirstChild(target).Team.BrickColor == 'Black' then -- More code...

I’d shorten the length using variables, and maybe loop through an array of “Whitelisted” teams that can’t be arrested

1 Like