Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Team change using a script?

Asked by 5 years ago

Hello, I am making a border game, I am having struggles with the team changing via a script. I made a gui and a countdown, but I want that after that certain countdown is over a script that changes you back to the immigrant team instead of the prisoners team.

If you can make me an advanced one (I dont need it, If you can then thanks), like whenever they leave and rejoin they are still in the prisoners team.

0
This is not a request site, please try your own code and if you face troubles come to us. mixgingengerina10 223 — 5y

2 answers

Log in to vote
0
Answered by
piRadians 297 Moderation Voter
5 years ago

Hi. Even though this is not a request website, I will gladly answer your question.

Try using the team service and the player's property "Team".

Example

local teams = game:GetService("Teams")
local desiredteam = teams.Immigrants -- or anything you'd like 
game.Players.PlayerAdded:Connect(function(plr) -- plr is the parameter for the player who just joined
if plr.Team == "Prisoners" then -- or whatever the jailed teams is 
wait(100) -- time in jail, you can change it.
plr.Team = desiredteam
end
end)

This should make a player join the team, and if he is in the prisoners team, it will wait 100 seconds, and then team him immigrant. Enjoy.

0
Should I parent the script in server script service? RealGamerChicken 17 — 5y
0
Most likely :) piRadians 297 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

This is not a request site. We will not write your scripts for you. That being said, I have a few tips for you. You can change a players team relatively easily with the Team property. Example:

player.Team = -- team you choose

To be able to change their team though, you will need to have the team object that you are going put them into. Example:

local teams = game:GetService("Teams") -- the recommended way of getting any service is :GetService() Services include: Players, ServerStorage, ReplicatedStorage, Teams, and so on
local teamWeWant = teams:FindFirstChild("immigrants") -- I took the team name from your explanation
player.Team = teamWeWant

I hope this helps and have a great day scripting!

Answer this question