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

Where do I put the script to assign one specific player to a team?

I am trying to create a game where there are two teams, a team of catchers and one team with just one specific player on it. I have the following script:

function onPlayerEntered(plr) if plr.UserId == "ReeowDiKitty" then
plr.TeamColor = BrickColor.new("New Yeller") plr:LoadCharacter() end end
game.Players.PlayerAdded:connect(onPlayerEntered)

But I have no idea where to put it and I have tried different places in Roblox studio and it has not worked. I am VERY new to this and I have not created a game on Roblox before and my Lua knowledge is next to nothing so please be aware that I have no idea of any technical terms. I have created my two teams and created the spawn locator blocks for each team and switched off the autoassign. Is there anything else I need to do?

Many thanks in advance, I'm tearing my hair out here!

8 comments

0

is it a script or local script

0

plr.UserId == ReeowDiKityy ?? Put the user id not username.

0

put end]

0

scriptinghelpers is not a request site. Put the script in ServerScriptService. Also please USE CODE BLOCK.

0

I've tried both having it as a script and a local script and neither has made a difference. I currently have it as a script.

0

I'm terribly sorry but I have no idea what a request site is. Surely asking for help in itself is a request. And I also did say I was very new to all of this, I have no idea what code block is. I simply asked someone who knew more about this than me for help, I'm sorry if I have broken any rules. And thank you all for your help and advice. I will make the changes and try again.

0

He is not trying to be rude, but others won't be able to under stand your script if you dont use code block

0

Thank you. The script still doesn't work anyway. Never mind, it must be something I'm either doing wrong or not doing at all. Thank you for your help.

1 answer

According to my knowledge, you have a few mistakes. Edited version:

local Teams = game:GetService("Teams")
local YellowTeam = Instance.new("Team", Teams)
YellowTeam.TeamColor = BrickColor.new("New Yeller")
function onPlayerEntered(plr)
if plr.UserId == --------
then
plr.TeamColor = YellowTeam.TeamColor
plr:LoadCharacter()
end end
game.Players.PlayerAdded:Connect(onPlayerEntered)
  1. You put a username instead of a UserId.
  2. I think you cannot just assign their team color, I may be wrong, but the edited version should be correct.
  3. You have to use :GetService() for Teams.

3 comments

0

Put this in a script, I don't think it will work under a local script unless you make remote events.

0

Thank you! I shall try that!

0

There must be something I am doing wrong as I can't get any of the scripts to work. Thank you all for your help anyway, back to the drawing board I guess :)

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