generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Why won't this script work?

Previous Thread :: Next Thread 
DracoTheSecond is not online. DracoTheSecond
Joined: 07 Nov 2011
Total Posts: 859
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
DracoTheSecond is not online. DracoTheSecond
Joined: 07 Nov 2011
Total Posts: 859
28 May 2014 02:44 PM
Bump
Report Abuse
SolarFloss is not online. SolarFloss
Joined: 08 Jan 2009
Total Posts: 63
28 May 2014 02:49 PM
I could be wrong, but try :FindFirstChild(), instead of :findFirstChild()
Report Abuse
SLY3 is not online. 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
DracoTheSecond is not online. DracoTheSecond
Joined: 07 Nov 2011
Total Posts: 859
28 May 2014 02:52 PM
Any other ideas?
Report Abuse
DracoTheSecond is not online. DracoTheSecond
Joined: 07 Nov 2011
Total Posts: 859
28 May 2014 03:05 PM
Bump!!!
Report Abuse
SuperiorEternal is not online. SuperiorEternal
Joined: 22 Aug 2009
Total Posts: 2365
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
DracoTheSecond is not online. DracoTheSecond
Joined: 07 Nov 2011
Total Posts: 859
28 May 2014 03:13 PM
Nope... Still not working
Report Abuse
Thaug is not online. 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
SuperiorEternal is not online. SuperiorEternal
Joined: 22 Aug 2009
Total Posts: 2365
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
DracoTheSecond is not online. DracoTheSecond
Joined: 07 Nov 2011
Total Posts: 859
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
DracoTheSecond is not online. DracoTheSecond
Joined: 07 Nov 2011
Total Posts: 859
28 May 2014 03:31 PM
Bump
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image