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

instance.new("Team") if player.name == (name) then player.Team = (teamName)?/

Asked by 3 years ago
Edited 3 years ago
player = game.Players.LocalPlayer

Team = Instance.new("Team")

Team.Name = "Owner"
Team.AutoAssignable = false
Team.TeamColor = BrickColor.Red()
Team.Parent = game.Teams

if player.Name == "VIImansxryVII" then
    player.Team = game.Teams("Owner")
end

why this script isn't working ?

the team is there but i dont gettin' moved to the team

(Workspace.VIImansxryVII.Dev Script:10: attempt to index nil with 'Name')

0
Is this put in a local script? Omq_ItzJasmin 666 — 3y
0
no its normal script VIImansxryVII 2 — 3y
0
You can't access LocalPlayer from a serverside script, you can only get LocalPlayer from a local script. Try using the PlayerAdded event Omq_ItzJasmin 666 — 3y
0
thank you too was offline a while VIImansxryVII 2 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I assumed this is answered but here it is anyways:

local Players = game:GetService('Players") 
local Teams = game:GetService("Teams") 


Players.PlayerAdded:Connect(function(player) 
If player.Name == ("yourname") then

local newTeam = Instance.new("Team")
newTeam.Name = "Owner"
newTeam.AutoAssignable = false
newTeam.TeamColor = BrickColor.Red()
newTeam.Parent = Teams

player.Team = Teams.Owner

end
end) 

Hopefully this works

Ad

Answer this question