|
| 29 Mar 2012 08:16 PM |
How would you find the player that clicked on a GUI? (I'm trying to move a character when a button is clicked). But you don't have to give me a whole script with CFrame. I just need the line with the :finFirstChild() in it. Any help would be appreciated.
+-Fishy |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2012 08:17 PM |
LocalScript:
local plyr = game.Players.LocalPlayer
Reg Script:
local plyr = A lot of parents
† KMXD † |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2012 08:17 PM |
| You could either use like 6 parents, or you could... um, sorry I forgot. |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2012 09:02 PM |
Alright, well here's my script, pretty self explanatory. When a TextButton is clicked, the GUI disappears (Works), and then it is supposed to move your character to a certain point (Doesn't work). I don't exactly know how to fix this, I've never dealt with CFraming a player, only Vector3ing a brick :P Any help would be appreciated.
local b = script.Parent local g = script.Parent.Parent.Parent local player = game.Players.LocalPlayer
function onClicked(click) if b.Name == "TextButton" then g:destroy() player.Torso.CFrame = player.Torso.CFrame.new(30, 4, -25) end end
script.Parent.MouseButton1Down:connect(onClicked)
+-Fishy |
|
|
| Report Abuse |
|
|
| |
|
|
| 29 Mar 2012 09:29 PM |
| What is b, the GUI itself? |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2012 09:40 PM |
Nope. b is the TextButton. g is the GUI itself.
+-Fishy |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2012 09:45 PM |
Haha, I meant to ask what g was. Silly me. Here you go.
local b = script.Parent local g = script.Parent.Parent.Parent local player = game.Players.LocalPlayer
function onClicked(click) if b.Name == "TextButton" then player.Character.Torso.CFrame = CFrame.new(30, 4, -25) -- The player and character are two different things. You want the character, not the player. g:destroy() -- Put this after, as the gui being removed before would cause the script to stop running. end end
script.Parent.MouseButton1Down:connect(onClicked)
|
|
|
| Report Abuse |
|
|
|
| 29 Mar 2012 09:50 PM |
Ohhh ok, thanks :P
+-Fishy |
|
|
| Report Abuse |
|
|