How do I use string instead of Team service?


So I have a game I’m making with different races/teams. Instead of using teams, how do I define a team/race using string? Thanks

You can insert a StringValue into their player and name it Race. Then you can read/write using player.Race.Value.

1 Like

Oh that makes sense. But how do I insert the string value into the player? Is it in starterplayerscripts or something?

If you want to insert a value into the player you can create a script in the Server Script Service:

game.Players.PlayerAdded:Connect(function(player)
local stringValue = Instance.new("StringValue")
stringValue.Parent = player
stringValue.Name = "Team" -- Name this whatever you want.
end)

That’s how you create a value inside the player

Thanks it worked. I’m still a bit confused on one thing though if you don’t mind answering.

How do I change from one team to another using the stringvalue? Do I change the value here in another script?
image

Yes, you can change the value of the string value from another script, but not a local one, a local script will only change the team for the client, the server will still think that he is in the same team.

Unless you fire a remote event

Instead of changing the value of Player.Team you do Player.Character.Team.Value

also nice you are makign a bleach game

But what are you trying to do? Like when you click a button, it changes your team?

Thanks, and yeah you can check my game here I tried making everything really detailed

Basically you start as a human with your avatar’s clothing. And when you get hit by a car, you will die and your team will change into a different team with specified clothing and tools.

Oh, so when you get hit, you can use the touched event to change the player’s race, if you want to get the player, you can check if the car’s touched event is a part of a player character, and if it is, get the player and change his string value race.

is this what you’ve needed help with?

yeah thanks I was just confused on using the stringvalues and now I know