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
 

OnClick

Previous Thread :: Next Thread 
Hopeless2 is not online. Hopeless2
Joined: 19 Oct 2011
Total Posts: 246
07 May 2013 03:54 PM
Hello.

Little stuck on how to make this, here's what I want to do.

This script is inside the Torso of a REAL person. A Click Detector is also inside the Torso too.

I'm trying to make it so when the Torso is clicked, it puts a GUI, named GUI1 (Inside the Torso owners PlayerGUI) into the clickers PlayerGUI, in Players.

Any help? - Thanks.
Report Abuse
StrikerBOY606 is not online. StrikerBOY606
Joined: 25 Oct 2010
Total Posts: 747
07 May 2013 03:55 PM
function clk()
--code stuff here
end

game.Workspace.Torso.ClickDetector.MouseClick:connect(clk)

Soemthing like that :/
Report Abuse
Hopeless2 is not online. Hopeless2
Joined: 19 Oct 2011
Total Posts: 246
07 May 2013 03:58 PM
I know that part. The bit i'm stumped on is getting the GUI, and moving it!
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
07 May 2013 04:20 PM
If the script is in the torso then:

function oc()
a = locate Gui
a:Clone().Parent = game.Players:GetPlayerFromCharacter(script.Parent Parent).PlayerGui
end

script.Parent.MouseButton1click:connect(oc)
Report Abuse
HotJazzCP is not online. HotJazzCP
Joined: 18 Dec 2010
Total Posts: 682
07 May 2013 04:32 PM
Thanks, that's a big chunk down.

Is there anyway to find who clicked it?
Report Abuse
Hopeless2 is not online. Hopeless2
Joined: 19 Oct 2011
Total Posts: 246
07 May 2013 04:33 PM
How would I do the "a = locate Gui"? As said above, doesn't that need to be the person who clicked the Torso?
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
07 May 2013 04:42 PM
I.don't understand? Do you want the clicker to see the Gui, or the player who gets clicked?

When I said "locate Gui" I meant like " game.Lighting.Gui"
Report Abuse
Hopeless2 is not online. Hopeless2
Joined: 19 Oct 2011
Total Posts: 246
08 May 2013 11:32 AM
I want the clicker to see the GUI. I'm not sure how to do that.
Report Abuse
Desperian is not online. Desperian
Joined: 07 Feb 2012
Total Posts: 3371
08 May 2013 11:36 AM
http://wiki.roblox.com/index.php/MouseClick_(Event)

function Bobby(Player)
print(Player.Name)
end

Something.Something.ClickDetector.MouseClick:connect(Bobby)



---- Player
--- PlayerGui
--- Backpack
--- StarterGear

Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
08 May 2013 11:58 AM
function oc(clicker)
a = locate Gui
a:Clone().Parent = game.Players:GetPlayerFromCharacter(clicker).PlayerGui
end

script.Parent.MouseButton1click:connect(oc)

Try
Report Abuse
Desperian is not online. Desperian
Joined: 07 Feb 2012
Total Posts: 3371
08 May 2013 12:03 PM
@Smiley,
You're not given a character you're given the player object that clicked.

a:Clone().Parent = clicker.PlayerGui

Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
08 May 2013 12:05 PM
Oh yeah
Report Abuse
Hopeless2 is not online. Hopeless2
Joined: 19 Oct 2011
Total Posts: 246
08 May 2013 12:09 PM
Okay.

Little confused, tried

"function oc(clicker)
a = locate Gui -- Still need to know how to get the GUI in the first place!
a:Clone().Parent = clicker.PlayerGui
end

script.Parent.MouseButton1click:connect(oc)"

Line 3,

"a:Clone().Parent = clicker.PlayerGui" '=' expected near 'a'
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
08 May 2013 12:31 PM
Put the GUi in lighting.

Then say a = game.Lighting.Gui -- change Gui to whatever it's called

try that, then tell me the output
Report Abuse
Hopeless2 is not online. Hopeless2
Joined: 19 Oct 2011
Total Posts: 246
08 May 2013 12:33 PM
Problem is, this is a system i'm making where the GUI NEEDS to be inside the Torso owners PlayerGUI.

Remember, this script is inside a ClickDetector, which is inside a Torso. I'm not sure how to make it so when another player clicks their torso, it gets the GUI out of the Torso owners PlayerGUI, and puts it in the Clickers PlayerGui.
Report Abuse
Desperian is not online. Desperian
Joined: 07 Feb 2012
Total Posts: 3371
08 May 2013 02:25 PM
@Smile,
You're using the wrong event. The event you use applies the GUI elements.

@OP,
local Player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)

function Clicky(Clicker) -- Functions can be named anything. Just thought I'd point this out.
Gui = Player.PlayerGui:FindFirstChild("GUI_NAME")
if Gui then
Gui.Parent = Clicker.PlayerGui -- Parents the clone to the clicker's backpack.
end

script.Parent.ClickDetector.MouseClick:connect(Clicky)

It really isn't hard... The above will simply move a GUI from the torso owner's PlayerGui and place it into the clicker's PlayerGui.
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