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: How to get the gui of a player?

Previous Thread :: Next Thread 
TheLagScript is not online. TheLagScript
Joined: 13 Apr 2012
Total Posts: 2004
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
TheLagScript is not online. TheLagScript
Joined: 13 Apr 2012
Total Posts: 2004
14 Feb 2014 07:27 PM
bump

~14 Years Old: C++/Lua/PHP~
Report Abuse
maxomega3 is not online. 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
TheLagScript is not online. TheLagScript
Joined: 13 Apr 2012
Total Posts: 2004
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
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