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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 09 Feb 2013 07:50 PM |
| @ash no I'm sorry he had a LOT more errors then what you stated! :/ |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 09 Feb 2013 07:53 PM |
| Oi hang on I forgot to add something to the script...Hang on! :) |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 09 Feb 2013 07:56 PM |
There are no spaces in my name!!! >:( I'm out!!! |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|
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
|
  |
| 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 |
|
|