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: On touched event not working for GUI

Previous Thread :: Next Thread 
Saodo is not online. Saodo
Joined: 26 Jul 2011
Total Posts: 1206
26 Oct 2013 08:00 AM
The GUI is not showing up when the door is touched. This is in a local script.

plyr = game.Players.LocalPlayer
GUI = plyr.PlayerGui.ScreenGui.Frame

script.Parent.Touched:connect(function(hit)

if hit.Parent:findFirstChild("Humanoid") then
GUI.Visible = true
end
end)
Report Abuse
ForceSky is not online. ForceSky
Joined: 30 Jul 2012
Total Posts: 2379
26 Oct 2013 08:18 AM
script.Parent.Touched

If you are using a LocalScript correctly, this should be in the playergui, and the playerGui can't be touched.

http://www.roblox.com/My/Groups.aspx?gid=890640
Report Abuse
Saodo is not online. Saodo
Joined: 26 Jul 2011
Total Posts: 1206
26 Oct 2013 08:52 AM
This script is inside a brick
Report Abuse
velibor is not online. velibor
Joined: 24 Nov 2009
Total Posts: 1003
26 Oct 2013 08:56 AM
A brick is Server side (Or it must be in a Instance of Client (Camera, Backpack, PlayerGui). Since Backpack and PlayerGui can't hold bricks, your only option will be the camera))

You are targeting this brick as Client, during the fact that you are using LocalPlayer (LocalScript). A LocalScript can't detect that kind of stuff.

So what you can do is just create a function that will do the same action when the Player has touched the brick, in a Script (Not a LocalScript)

~ Velibor
Report Abuse
Saodo is not online. Saodo
Joined: 26 Jul 2011
Total Posts: 1206
26 Oct 2013 08:58 AM
so you are saying just put it in a normal script?
Report Abuse
velibor is not online. velibor
Joined: 24 Nov 2009
Total Posts: 1003
26 Oct 2013 08:59 AM
Yes, but then you can't use LocalPlayer anymore.
Report Abuse
Saodo is not online. Saodo
Joined: 26 Jul 2011
Total Posts: 1206
26 Oct 2013 09:03 AM
So what is the alternative?
Report Abuse
enyahs7 is not online. enyahs7
Joined: 25 Apr 2008
Total Posts: 9820
26 Oct 2013 09:08 AM
function SHOWGUI(hit)
if hit.Parent:FindFirstChild("Humanoid") then
usr = game.Players:GetPlayerFromCharacter(hit.Parent)
usr.PlayerGui.ScreenGui.Frame.Visible = true
end
end

script.Parent.Touched:connect(SHOWGUI)
Report Abuse
velibor is not online. velibor
Joined: 24 Nov 2009
Total Posts: 1003
26 Oct 2013 09:08 AM
Hierachy in Studio
- Workspace
-- Brick
--- Script

- Player
-- PlayerGui
--- GUI
---- Element

Put a Script in the Brick, make a function that validates or we have a real Player and not just something else that touched it.

Check or the Player has a Character

Do action to PlayerGui by using pcall()

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