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

If player is HR they get teamed to HR team What am I doing wrong?

function onPlayerEntered(plyr)
if plyr:IsInGroup(2595428) and if plyr.rank.("1") then.game.players.TeamColor = BrickColor.new("Bright blue") then  
plyr.TeamColor = BrickColor.new("Medium stone grey") 
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)

First of all I am trying to make it to where if someone is a HR in my group they get teamed to Bright blue team. And if someone is not a HR they get teamed to Medium stone grey team.

2 answers

✓ Accepted answer

First of all why is it then.game.players.TeamColor = BrickColor.new("Bright blue") then. You cannot have then.

Here is the full code;

GroupId = 25954284 --Your group ID here (the numbers in: http://www.roblox.com/My/Groups.aspx?gid=xxxxxxxx)
GroupRank = 1 ----The rank number in group>Group Admin>Rank>Number (0-255) Set to 0 if you want everyone to be able to get the tools.

function onPlayerEntered(hit) 
	local p = game.Players:GetPlayerFromCharacter(hit.Parent)
	if p:GetRankInGroup(GroupId) >= GroupRank and p:IsInGroup(GroupId) then
		game.Players.LocalPlayer.TeamColor = BrickColor.new("Bright blue")  -- Set Team
	else
		game.Players.LocalPlayer.TeamColor = BrickColor.new("Medium Stone Grey")  -- Set Team
	end 
end  

game.Players.PlayerAdded:connect(onPlayerEntered)

2 comments

0

Bruh, the paramater is the player, why did you make it hit? You did not even have to make the 'p' variable.

0

Because every good scripter makes it (hit). Ultraw recommend me to do this so I am doing it, also many other scripters do this.

I know I am late and this question has been accepted but there is an easier way of doing this than 'TheUniPiggy' did. I'm going to take his code but re-write some of it.

GroupId = 25954284 --Your group ID here (the numbers in: http://www.roblox.com/My/Groups.aspx?gid=xxxxxxxx)
GroupRank = 1 ----The rank number in group>Group Admin>Rank>Number (0-255) Set to 0 if you want everyone to be able to get the tools.

function onPlayerEntered(Player) --The parameter is the player
    -- You don't need that 'p' variable since we already have the player.
    if Player:GetRankInGroup(GroupId) >= GroupRank and Player:IsInGroup(GroupId) then
        Player.TeamColor = BrickColor.new("Bright blue")  -- Set Team
    else
       Player.TeamColor = BrickColor.new("Medium Stone Grey")  -- Set Team
    end 
end  

game.Players.PlayerAdded:connect(onPlayerEntered)

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