You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to be able to give the player specific items based on their team
What is the issue? Include screenshots / videos if possible!
The issue is it just doesn’t work.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried using playeradded, however it just doesn’t work and automatically assumes the player has chosen a team. None of the solutions I found on the developer hub have worked.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Team = game:GetService("Teams")
local Soldier = Team["Soldiers"]
local Wizard = Team["Wizards"]
local WizardPowers = game:GetService("ServerStorage"):WaitForChild("WizardPowers")
game:GetService("Players").PlayerAdded:Connect(function(Player)
repeat wait() until Player.Team == game.Teams["Wizards"] or game.Teams["Soldiers"]
print(Player.Name , "has changed teams!")
local Backpack = Player:WaitForChild("Backpack")
if Player.Team == Wizard then
WizardPowers:Clone().Parent = Player.Backpack
print(Player, "got their powers!")
elseif Player.Team == Soldier then
-- Not done yet
end
end)
This is a script inside of ServerScriptService.
Any help would be greatly appreciated.
It appears you didn’t do the first if statement correctly!
local Soldier = Team["Soldiers"]
local Wizard = Team["Wizards"]
local WizardPowers = game:GetService("ServerStorage"):WaitForChild("WizardPowers")
game:GetService("Players").PlayerAdded:Connect(function(Player)
repeat wait() until Player.Team == game.Teams["Wizards"] or game.Teams["Soldiers"]
print(Player.Name , "has changed teams!")
local Backpack = Player:WaitForChild("Backpack")
if Player.Team == game.Teams:FindFirstChild('Wizard') then
WizardPowers:Clone().Parent = Player.Backpack
print(Player, "got their powers!")
elseif Player.Team == Soldier then
-- Not done yet
end
end)
local Soldier = game.Teams:FindFirstChild('Soldiers')
local Wizard = game.Teams:FindFirstChild('Wizard')
local WizardPowers = game:GetService("ServerStorage"):WaitForChild("WizardPowers")
game:GetService("Players").PlayerAdded:Connect(function(Player)
repeat task.wait() until Player.Team == Soldier or Player.Team == Wizard
print(Player.Name , "has changed teams!")
local Backpack = Player:WaitForChild("Backpack")
if Player.Team == Wizard then
WizardPowers:Clone().Parent = Player.Backpack
print(Player, "got their powers!")
elseif Player.Team == Soldier then
-- Not done yet
end
end)