|
| 14 Feb 2014 07:20 PM |
I need to get a players GUI via a script. I have this, but it doesn't work
Light = script.Parent.Light.SpotLight flashlight = script.Parent
on = false
function batteryOn(Player) battery = Player.PlayerGui.ScreenGui.FrameRed.FrameGreen wait(2) battery.AbsoluteSize.X = battery.Size.X.Offset - 5 end
flashlight.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) if key == "e" and on == false then print('Flashlight is on') Light.Brightness = 100 on = true while on == true do batteryOn() end elseif key == "e" and on == true then print('Flashlight of off') Light.Brightness = 0 on = false end end) end)
~14 Years Old: C++/Lua/PHP~ |
|
|
| Report Abuse |
|
|
|
| 14 Feb 2014 07:27 PM |
bump
~14 Years Old: C++/Lua/PHP~ |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 14 Feb 2014 07:29 PM |
| I think you need to use a LocalScript, and then use LocalPlayer. |
|
|
| Report Abuse |
|
|
|
| 14 Feb 2014 07:40 PM |
changed it to a localscript and did this: Light = script.Parent.Light.SpotLight flashlight = script.Parent --battery = script.Parent.Parent.Parent.PlayerGui.ScreenGui.FrameRed.FrameGreen
on = false
function batteryOn() battery = LocalPlayer.PlayerGui.ScreenGui.FrameRed.FrameGreen wait(2) battery.AbsoluteSize.X = battery.Size.X.Offset - 5 end
flashlight.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) if key == "e" and on == false then print('Flashlight is on') Light.Brightness = 100 on = true while on == true do batteryOn() end elseif key == "e" and on == true then print('Flashlight of off') Light.Brightness = 0 on = false end end) end)
error: 20:39:16.530 - Players.Player1.Backpack.Flashlight.Flashlight:8: attempt to index global 'LocalPlayer' (a nil value) 20:39:16.531 - Script 'Players.Player1.Backpack.Flashlight.Flashlight', Line 8 - global batteryOn 20:39:16.532 - Script 'Players.Player1.Backpack.Flashlight.Flashlight', Line 20 20:39:16.534 - stack end 20:39:16.535 - Disconnected event because of exception
~14 Years Old: C++/Lua/PHP~ |
|
|
| Report Abuse |
|
|