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 » Scripters
Home Search
 

Re: W001: Unknown global

Previous Thread :: Next Thread 
Bananacb is online. Bananacb
Joined: 13 Jun 2008
Total Posts: 5188
12 Apr 2015 08:58 PM
Errors I can't solve in the script...
W001: Unknown global 'hit'
W001: Unknown global 'player'
W001: Unknown global 'Backpack'
----------------------------------------------------------------------------------------

--Touch function:
brick = script.Parent

--Adding parents won't help you unless you moved the script...
brick.Touched:connect(function(hit)
if hit.Parent then--Just make sure hit has a parent in case someone has a bow or gun or like touches and leaves instantly so it won't break
if game.Players:FindFirstChild(hit.Parent.Name) then
if game.Players.Backpack:FindFirstChild("Hockey Stick") then
print'A player touched the brick!'
local player = game.Players:FindFirstChild(hit.Parent.Name)--Makes the player a local variable
if player.TeamColor == BrickColor.new'Bright blue' or Backpack.HockeyStick.blade.BrickColor == BrickColor.new("Bright blue") then--checks if player is on the blue team
print(player.Name..' is on the blue team.')
if script.Parent.Parent.Control.Value == 1 then
script.Parent.Parent.TeamTwoAssists.Value = "?"
script.Parent.Parent.TeamTwoAssist.Value = "?"
script.Parent.Parent.TeamTwoGoal.Value = hit.Parent.Parent.Name
end
end
end
end
end
end)

if script.Parent.Parent.Control.Value == 2 and hit.Parent.Parent.Name == script.Parent.Parent.TeamTwoGoal.Value then
print'Bluehi'
end

if hit.Parent.Name ~= script.Parent.Parent.TeamTwoGoal.Value then
script.Parent.Parent.TeamTwoAssists.Value = script.Parent.Parent.TeamTwoAssist.Value
script.Parent.Parent.TeamTwoAssist.Value = script.Parent.Parent.TeamTwoGoal.Value
script.Parent.Parent.TeamTwoGoal.Value = hit.Parent.Name

script.Parent.Parent.Control.Value = 2
elseif player.TeamColor == BrickColor.new'Bright red' or Backpack.HockeyStick.blade.BrickColor == BrickColor.new("Bright red") then --checks if player is on the red team

print(player.Name..' is on the red team.')
if script.Parent.Parent.Control.Value == 1 then
script.Parent.Parent.TeamTwoAssists.Value = "?"
script.Parent.Parent.TeamTwoAssist.Value = "?"
script.Parent.Parent.TeamTwoGoal.Value = hit.Parent.Parent.Name
end
end
if hit.Parent.Name ~= script.Parent.Parent.TeamOneGoal.Value then
script.Parent.Parent.TeamOneAssists.Value = script.Parent.Parent.TeamOneAssist.Value
script.Parent.Parent.Parent.TeamOneAssist.Value = script.Parent.Parent.TeamOneGoal.Value
script.Parent.Parent.TeamOneGoal.Value = hit.Parent.Name
end
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
12 Apr 2015 09:00 PM
you can't use hit and player outside of your function

and you just made up 'BackPack'.
Report Abuse
Bananacb is online. Bananacb
Joined: 13 Jun 2008
Total Posts: 5188
12 Apr 2015 09:00 PM
Okay that should help.
Report Abuse
Bananacb is online. Bananacb
Joined: 13 Jun 2008
Total Posts: 5188
12 Apr 2015 09:10 PM
What about...
Error (24,5) Expected') '(to close'('at line 5) got if'
=======================================================================================

--Touch function:
brick = script.Parent

--Adding parents won't help you unless you moved the script...
brick.Touched:connect(function(hit)
if hit.Parent then--Just make sure hit has a parent in case someone has a bow or gun or like touches and leaves instantly so it won't break
if game.Players:FindFirstChild(hit.Parent.Name) then
if game.Players.Backpack:FindFirstChild("Hockey Stick") then
print'A player touched the brick!'
local player = game.Players:FindFirstChild(hit.Parent.Name)--Makes the player a local variable
if player.TeamColor == BrickColor.new'Bright blue' or Backpack.HockeyStick.blade.BrickColor == BrickColor.new("Bright blue") then--checks if player is on the blue team
print(player.Name..' is on the blue team.')
if script.Parent.Parent.Control.Value == 1 then
script.Parent.Parent.TeamTwoAssists.Value = "?"
script.Parent.Parent.TeamTwoAssist.Value = "?"
script.Parent.Parent.TeamTwoGoal.Value = hit.Parent.Parent.Name
end
end
end
end
end
end

if script.Parent.Parent.Control.Value == 2 and hit.Parent.Parent.Name == script.Parent.Parent.TeamTwoGoal.Value then
print'Bluehi'
end

if hit.Parent.Name ~= script.Parent.Parent.TeamTwoGoal.Value then
script.Parent.Parent.TeamTwoAssists.Value = script.Parent.Parent.TeamTwoAssist.Value
script.Parent.Parent.TeamTwoAssist.Value = script.Parent.Parent.TeamTwoGoal.Value
script.Parent.Parent.TeamTwoGoal.Value = hit.Parent.Name

script.Parent.Parent.Control.Value = 2
elseif player.TeamColor == BrickColor.new'Bright red' or Backpack.HockeyStick.blade.BrickColor == BrickColor.new("Bright red") then --checks if player is on the red team

print(player.Name..' is on the red team.')
if script.Parent.Parent.Control.Value == 1 then
script.Parent.Parent.TeamTwoAssists.Value = "?"
script.Parent.Parent.TeamTwoAssist.Value = "?"
script.Parent.Parent.TeamTwoGoal.Value = hit.Parent.Parent.Name
end
end
if hit.Parent.Name ~= script.Parent.Parent.TeamOneGoal.Value then
script.Parent.Parent.TeamOneAssists.Value = script.Parent.Parent.TeamOneAssist.Value
script.Parent.Parent.Parent.TeamOneAssist.Value = script.Parent.Parent.TeamOneGoal.Value
script.Parent.Parent.TeamOneGoal.Value = hit.Parent.Name
end)
Report Abuse
Freezesore is not online. Freezesore
Joined: 01 Aug 2013
Total Posts: 10
16 Jun 2017 02:34 PM
I usually define what it is,

For example:

If my Objects are Named something different like a TestFrame (Originally a Frame)
then i would see a blue underlined line underneath the named Object.

My solution would be doing this:

Frame = script.Parent.Parent.TestFrame

That would then define what Frame your talking about..


Hope that helps..

Regards,

Freezesore
Report Abuse
TheAuthenticator is not online. TheAuthenticator
Joined: 05 Sep 2010
Total Posts: 162
16 Jun 2017 07:06 PM
you didnt end the function on line 5 with an end)
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
16 Jun 2017 07:08 PM
In behalf of the OP:
Thanks, Freeze! You just saved this two-year overdue project and kept him from getting fired as a result!


Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
16 Jun 2017 09:44 PM
^
Report Abuse
Freezesore is not online. Freezesore
Joined: 01 Aug 2013
Total Posts: 10
30 Jul 2017 11:55 AM
Not scripted in quite a while I don't know if what i have posted is correct :3
Report Abuse
spacesplitter is not online. spacesplitter
Joined: 10 Jul 2015
Total Posts: 44
30 Jul 2017 12:38 PM
local variables can only be accessed from that code block, remove the local OR u can do
this code

--
local string1="I am a string"
local function Print()
do
print(string1)
end
end
Print()
Report Abuse
Freezesore is not online. Freezesore
Joined: 01 Aug 2013
Total Posts: 10
31 Aug 2017 04:39 PM
At least I helped.
















:P
Report Abuse
ExplodeLikeAVolcano is not online. ExplodeLikeAVolcano
Joined: 02 Nov 2013
Total Posts: 12146
31 Aug 2017 04:57 PM
Why are you continuing to bump old threads?


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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