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: Can't get this to work. New to SurfaceGui Scripting.

Previous Thread :: Next Thread 
Sekheret332 is not online. Sekheret332
Joined: 22 Nov 2011
Total Posts: 490
22 Apr 2014 05:30 PM
So, basically, this is the heirarchy.

Workspace
-InfoComputer
--Computer (Which is the Surface Gui)
---Frame
----Processor (The following script)
----ImageButton



The ImageButton is just a decal of the place I want to teleport to. Here is the script:



local f = script.Parent.ImageButton

f.MouseButton1Down:connect(function()
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
game:getService("TeleportService"):TeleportToPlaceInstance(152644021, player)
end
end)

Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Apr 2014 05:35 PM
local player = game.Players:GetPlayerFromCharacter(hit.Parent)

hit isnt defined
Report Abuse
Sekheret332 is not online. Sekheret332
Joined: 22 Nov 2011
Total Posts: 490
22 Apr 2014 05:35 PM
How do I define it...?
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Apr 2014 05:37 PM
function(hit)
Report Abuse
Sekheret332 is not online. Sekheret332
Joined: 22 Nov 2011
Total Posts: 490
22 Apr 2014 05:38 PM
Omg... I should've known that.
..
Report Abuse
Sekheret332 is not online. Sekheret332
Joined: 22 Nov 2011
Total Posts: 490
22 Apr 2014 05:39 PM
I get this in output still:

18:38:41.820 - Script 'Workspace.InfoComputer.Computer.Frame.Processor', Line 4
18:38:41.821 - stack end
18:38:41.821 - Disconnected event because of exception


Note, I'm in studio. Should I try in-game?
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Apr 2014 05:39 PM
I like your idea

Make it so the teleporter is like an icon of your place pic or somethin
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Apr 2014 05:40 PM
Yea try in game


Also remember that F9 is online output system
Report Abuse
Sekheret332 is not online. Sekheret332
Joined: 22 Nov 2011
Total Posts: 490
22 Apr 2014 05:40 PM
Wow, really? I've always wanted one. o.O
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Apr 2014 05:41 PM
http://blog.roblox.com/2014/04/find-bugs-in-live-games-with-the-developer-console/?utm_source=rss&utm_medium=rss&utm_campaign=find-bugs-in-live-games-with-the-developer-console
Report Abuse
Sekheret332 is not online. Sekheret332
Joined: 22 Nov 2011
Total Posts: 490
22 Apr 2014 05:44 PM
Okay, now here's what I get.

Content failed because Not Found
Workspace.InfoComputer.Computer.Frame.Processor:4: attempt to index local 'hit' (a number value)
Report Abuse
Sekheret332 is not online. Sekheret332
Joined: 22 Nov 2011
Total Posts: 490
22 Apr 2014 05:45 PM
Overall output is this:

Content failed because Not Found
Workspace.InfoComputer.Computer.Frame.Processor:4: attempt to index local 'hit' (a number value)
Script 'Workspace.InfoComputer.Computer.Frame.Processor', Line 4
stack end
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Apr 2014 05:48 PM
Oh, the argument of MouseButton1Down doesnt relate to player, oops lol
Report Abuse
Sekheret332 is not online. Sekheret332
Joined: 22 Nov 2011
Total Posts: 490
22 Apr 2014 05:49 PM
So I do what, now?
Report Abuse
Sekheret332 is not online. Sekheret332
Joined: 22 Nov 2011
Total Posts: 490
22 Apr 2014 05:55 PM
Bump. :/
Report Abuse
Sekheret332 is not online. Sekheret332
Joined: 22 Nov 2011
Total Posts: 490
22 Apr 2014 05:55 PM
New/Current Script



local f = script.Parent.ImageButton

f.MouseButton1Down:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
game:getService("TeleportService"):TeleportToPlaceInstance(152644021, player)
end
end)

Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
22 Apr 2014 05:59 PM
From the Wiki:
"Note: SurfaceGuis must be descendants of PlayerGui in order to know the player who is interacting with it."
You have to put the SurfaceGui in PlayerGui, and make a localscript, which sets the adornee to the part. Then you can change the player variable so it references the player (using the .Parent property to link back to the player). You also can't have the hit in the parenthesis of the function, as MouseButton1Down does not return anything.

Here's my siggy... Done.
Report Abuse
Sekheret332 is not online. Sekheret332
Joined: 22 Nov 2011
Total Posts: 490
22 Apr 2014 06:03 PM
How would one do that. ..
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