Superfryx
|
  |
| Joined: 01 Aug 2011 |
| Total Posts: 3253 |
|
|
| 24 May 2013 04:37 PM |
I am experimenting with guis. But why won't this work. It makes it so when you click on a button it gives you a tool and then teleports you. In the output it said Players.Player1.PlayerGui.ScreenGui.Frame.TextButton.Script:4: attempt to index global 'Player' (a nil value)
Also how do I make it remove the gui when you click it?
local Text=script.Parent local Tel2=game.Workspace.Tel2 local Gear=script.Parent.Tool local Location=game:GetService('Players'):GetPlayerFromCharacter(Player.Parent)--Finds player folder for our player local New=Gear:Clone() local Player=game.Players.LocalPlayer.Character
function onClick() New.Parent=Location.Backpack -------------------------------------------------------------------------- Player.Torso.CFrame = CFrame.new(Tel2.Position+Vector3.new(0,3,0))--Moves player to teleporter but up 3 studs higher t.MouseButton1Click:connect(onClick) end Text.MouseButton1Click:connect(onClick)
|
|
|
| Report Abuse |
|
|
Desperian
|
  |
| Joined: 07 Feb 2012 |
| Total Posts: 3371 |
|
|
| 24 May 2013 04:41 PM |
| Because 'Player' is defined after you trying to use the variable. Also, you're trying to use ':GetPlayerFromCharacter()' on Workspace. |
|
|
| Report Abuse |
|
|
Superfryx
|
  |
| Joined: 01 Aug 2011 |
| Total Posts: 3253 |
|
|
| 25 May 2013 09:41 AM |
| I dont get it. Im really new to scripting and guis. I tried some stuff but it didnt work. |
|
|
| Report Abuse |
|
|
Desperian
|
  |
| Joined: 07 Feb 2012 |
| Total Posts: 3371 |
|
|
| 25 May 2013 09:55 AM |
| Put the 'local Player = Bleh Bleh' bit before the line that tries using it... |
|
|
| Report Abuse |
|
|
Superfryx
|
  |
| Joined: 01 Aug 2011 |
| Total Posts: 3253 |
|
|
| 26 May 2013 10:26 AM |
| It acctully matters where I use locals? |
|
|
| Report Abuse |
|
|
Desperian
|
  |
| Joined: 07 Feb 2012 |
| Total Posts: 3371 |
|
|
| 26 May 2013 10:37 AM |
It matters where you define anything... You've got to define the variable before the line that another tries using it, if that makes sense.
|
|
|
| Report Abuse |
|
|