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: _G and LocalScripts

Previous Thread :: Next Thread 
Malcolt3 is not online. Malcolt3
Joined: 17 Dec 2009
Total Posts: 11442
09 Mar 2014 11:24 AM
Are any efficient ways to either

1) access the player mouse from a script that isn't local

or

2) easily access _G from a localscript
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
09 Mar 2014 11:25 AM
no
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
09 Mar 2014 11:26 AM
1.use a tool.Equipped event,and you can easily get the mouse
2._G can not be accessed from a localscript
Report Abuse
Malcolt3 is not online. Malcolt3
Joined: 17 Dec 2009
Total Posts: 11442
09 Mar 2014 12:05 PM
@island So I managed to get the mouse with a tool and set it to a global variable, but none of the events ever fire when I try to use it in another script. For example, I have a KeyDown event that's set to do something, but nothing ever happens.
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
09 Mar 2014 12:06 PM
post le script
Report Abuse
Malcolt3 is not online. Malcolt3
Joined: 17 Dec 2009
Total Posts: 11442
09 Mar 2014 12:16 PM
Here's the tool script:



repeat wait() until script.Parent.Parent ~= game.StarterPack

tool = script.Parent

h = Instance.new('Hint', Workspace)
h.Text = '1'

tool.Equipped:connect(function(m)
h.Text = '2'
_G.Mouse = m
h.Text = '3'
tool:Destroy()
h.Text = '4'
end)





And here's the script that tries to use the mouse:

gui = script.Parent.Parent
repeat wait() until gui.Parent ~= game.StarterGui

player = gui.Parent.Parent

mouse = nil
tool = player.Backpack.Tool
tool.Equipped:connect(function(m)
mouse = m
end)

repeat wait() until mouse

mouse.KeyDown:connect(function(key)
if key == 'b' then
if tray_backpack.Visible == true then
closeall()
elseif tray_backpack.Visible == false then
closeall()
tray_backpack.Visible = true
end
end
end)
Report Abuse
Malcolt3 is not online. Malcolt3
Joined: 17 Dec 2009
Total Posts: 11442
09 Mar 2014 12:17 PM
All of the functions in the second script work; it seems like the KeyDown event isn't activated.
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
09 Mar 2014 12:20 PM
mouse = _G["Mouse"]
Report Abuse
Malcolt3 is not online. Malcolt3
Joined: 17 Dec 2009
Total Posts: 11442
09 Mar 2014 12:35 PM
@Dueling Switching _G.Mouse to _G["Mouse"] doesn't do anything.
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