|
| 28 May 2014 02:35 PM |
Hey guys,
This is the script I have:
local Land1 = game.Workspace.Land1Owner
function onPlayerEntered(NewPlayer) if Land1.Value == "Nobody" then Land1.Value = "" ..NewPlayer.Name local Team1Name = "" ..NewPlayer.Name.. "'s Empire" game:GetService('Teams'):findFirstChild("Team1").Name = Team1Name NewPlayer.TeamColor = game:GetService('Teams'):findFirstChild(Team1Name).TeamColor NewPlayer.Neutral = false end end
game.Players.ChildAdded:connect(onPlayerEntered)
It's picking up an error on the line in which the team name should change. Why? |
|
|
| Report Abuse |
|
|
| |
|
|
| 28 May 2014 02:49 PM |
| I could be wrong, but try :FindFirstChild(), instead of :findFirstChild() |
|
|
| Report Abuse |
|
|
SLY3
|
  |
| Joined: 10 Jul 2008 |
| Total Posts: 1700 |
|
|
| 28 May 2014 02:50 PM |
| Both work @solar, if findFirstChild() didn't work then all old scripts would break. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 28 May 2014 03:07 PM |
local Land1 = game.Workspace.Land1Owner
function onPlayerEntered(NewPlayer) if Land1.Value == "Nobody" then Land1.Value = "" ..NewPlayer.Name local Team1Name = "" ..NewPlayer.Name.. "'s Empire" game:GetService('Teams'):findFirstChild("Team1").Name = Team1Name NewPlayer.TeamColor = game:GetService('Teams'):findFirstChild(Team1Name).TeamColor NewPlayer.Neutral = false end end
game.Players.ChildAdded:connect(onPlayerEntered)
local Land1 = Workspace.Land1owner
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(chr) if Land1.Value == "Nobody" then Land1.Value = ""..chr.Name local Team1Name = "" ..chr.Name.. "'s Empire" game.Teams:findFirstChild("Team1").Name = Team1Name chr.TeamColor = game.Teams:findFirstChild(Team1Name).TeamColor chr.Neutral = false end end |
|
|
| Report Abuse |
|
|
| |
|
Thaug
|
  |
| Joined: 08 Apr 2013 |
| Total Posts: 651 |
|
|
| 28 May 2014 03:14 PM |
| I thought you aren't allowed to name variables using numbers. :/ |
|
|
| Report Abuse |
|
|
|
| 28 May 2014 03:18 PM |
local Land1 = Workspace.Land1owner
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(chr) if Land1.Value == "Nobody" then Land1.Value = ""..chr.Name local Team1Name = "" ..chr.Name.. "'s Empire" game.Teams:findFirstChild("Team1").Name = Team1Name chr.TeamColor = game.Teams:findFirstChild(Team1Name).TeamColor chr.Neutral = false end end
It is probably problems in your API |
|
|
| Report Abuse |
|
|
|
| 28 May 2014 03:27 PM |
Here's the current script:
local Land1Owner = game.Workspace.Land1.Land1Owner
function onPlayerEntered(NewPlayer) if Land1Owner.Value == "Nobody" then Land1Owner.Value = "" ..NewPlayer.Name Land1Owner.Parent.TeamName.Value = "" ..NewPlayer.Name.. "'s Empire" game:GetService('Teams'):FindFirstChild("Team1").Name = "" ..Land1Owner.Parent.TeamName.Value end end
game.Players.ChildAdded:connect(onPlayerEntered)
The error appears on the line "game:GetService...". I also tried game.Teams but neither worked. Is it possible to change a team name via script? |
|
|
| Report Abuse |
|
|
| |
|
|
| 28 May 2014 03:35 PM |
local Land1Owner = game.Workspace.Land1.Land1Owner
function onPlayerEntered(NewPlayer) if Land1Owner.Value == "Nobody" then Land1Owner.Value = NewPlayer.Name Land1Owner.Parent.TeamName.Value = (NewPlayer.Name.. "'s Empire") if game.Teams:FindFirstChild("Team1") then game.Teams.Team1.Name = (NewPlayer.Name.. "'s Empire") end end end
game.Players.PlayerAddedAdded:connect(onPlayerEntered) |
|
|
| Report Abuse |
|
|