I have this script that teleports a player to a part depending on which team they are on. But it teleports each team player to a random part and I want each player to have a dedicated part.
local Home = workspace.AwayPart:GetChildren()
local Away = workspace.HomePart:GetChildren()
local function Teleport(players,Location)
for i,player in pairs(players) do
if player then
local character = player.Character or player.CharacterAdded:wait()
if character and character.Parent then
character:PivotTo(Location[i].CFrame + Vector3.new(0,5,0))
end
end
end
end
local teams = game:GetService("Teams"):GetTeams()
for _, team in pairs(teams) do
if team.Name == "Home" then
Teleport(team:GetPlayers(),Home)
if team.Name == "Away" then
Teleport(team:GetPlayers(),Away)
end
end
end
You can add an attribute to an object using :SetAttribute(), or you can scroll down on properties while having an object selected and change them there.
To get an attribute use :GetAttribute()
Read this if you want to know more about attributes: Instance Attributes
local character = player.Character or player.CharacterAdded:wait()
if character and character.Parent then
character:WaitForChild("HumanoidRootPart"):PivotTo(Location[i].CFrame + Vector3.new(0,5,0))