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: Gui teleport script

Previous Thread :: Next Thread 
redlo43 is not online. redlo43
Joined: 16 Feb 2011
Total Posts: 4722
09 Feb 2013 07:46 PM
function onClick()
print("Clicked")
local human = Click.Parent:findFirstChild("Humanoid")
if (human ~= nil) then
print("It is working")
Click.Parent.Torso.CFrame = CFrame.new(Vector3.new(0, 50, 0))
end

element.MouseButton1Click:connect(onClick)

--what is wrong with this script? It's a gui teleportation script. On click, you teleport to 0, 50, 0. Cframe.
HELP
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 07:49 PM
you need to add another end, also is the "Click" defined e.g 'Click = script.Parent' e.t.c
Report Abuse
Sonofmetal is not online. Sonofmetal
Joined: 07 Feb 2012
Total Posts: 1159
09 Feb 2013 07:49 PM
try this:

function onClick(plr)
print("Clicked")
if(plr.Character:FindFirstChild("Torso"))then
plr.Character.Torso.CFrame = CFrame.new(Vector3.new(0, 50, 0))
end
end

element.MouseButton1Click:connect(onClick)

report any errors!
Report Abuse
Sonofmetal is not online. Sonofmetal
Joined: 07 Feb 2012
Total Posts: 1159
09 Feb 2013 07:50 PM
@ash no I'm sorry he had a LOT more errors then what you stated! :/
Report Abuse
redlo43 is not online. redlo43
Joined: 16 Feb 2011
Total Posts: 4722
09 Feb 2013 07:51 PM
oh ya, I fixed the end error just a few secs ago, bug I don't get the correct declaration for Click
Report Abuse
Sonofmetal is not online. Sonofmetal
Joined: 07 Feb 2012
Total Posts: 1159
09 Feb 2013 07:53 PM
Oi hang on I forgot to add something to the script...Hang on! :)
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 07:54 PM
Well considering this is a GUI, Click would be set to however many parents it takes to get to 'PlayerGui' e.g. Script -> Frame -> ScreenGui -> PlayerGui = 3 Parents, then you would have to do another parent and then get the character, therefore

'script.Parent.Parent.Parent.Parent.Character'
Report Abuse
Sonofmetal is not online. Sonofmetal
Joined: 07 Feb 2012
Total Posts: 1159
09 Feb 2013 07:54 PM
try this:

element=script.Parent.ClickDetector--Please tell me if this is what you're doing!

function onClick(plr)
print("Clicked")
if(plr.Character:FindFirstChild("Torso"))then
plr.Character.Torso.CFrame = CFrame.new(Vector3.new(0, 50, 0))
end
end

element.MouseClick:connect(onClick)

report any errors!
Report Abuse
Sonofmetal is not online. Sonofmetal
Joined: 07 Feb 2012
Total Posts: 1159
09 Feb 2013 07:55 PM
WHOA WHOA WHOA!!! Wait a minute this is a Gui? I thought it was a clickdetector...well another lesson...clarify better!
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 07:55 PM
Son of metal, he's using a GUI, so therefore that would be incorrect.
Report Abuse
Sonofmetal is not online. Sonofmetal
Joined: 07 Feb 2012
Total Posts: 1159
09 Feb 2013 07:56 PM
After all I've done I'm NOT going to explain THIS one also! Let ash do it! She thinks she knows everything...... :/
Report Abuse
Sonofmetal is not online. Sonofmetal
Joined: 07 Feb 2012
Total Posts: 1159
09 Feb 2013 07:56 PM
There are no spaces in my name!!! >:(
I'm out!!!
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 07:57 PM
Click = script.Parent.Parent.Parent.Parent --Goes to the player (change as necessary)

element.MouseButton1Click:connect(function()
print"Clicked"
if Click.Character ~= nil then
Click.Character.Torso.CFrame = CFrame.new(Vector3.new(0,50,0))
end
end)
Report Abuse
Sonofmetal is not online. Sonofmetal
Joined: 07 Feb 2012
Total Posts: 1159
09 Feb 2013 07:58 PM
lol sorry I can't resist...you forgot to set the path to the element! LOL!
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 08:00 PM
I assumed he'd already done that. btw, I'm not a girl ;]
Report Abuse
Sonofmetal is not online. Sonofmetal
Joined: 07 Feb 2012
Total Posts: 1159
09 Feb 2013 08:02 PM
ok :L
Report Abuse
redlo43 is not online. redlo43
Joined: 16 Feb 2011
Total Posts: 4722
09 Feb 2013 08:06 PM
does the declaration of something come before or after the function? or does it depend?
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 08:10 PM
If you're declaring your 'elements' then you want it outside of the function, because you need it to be available for the function to use...
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