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: OnClick() Function

Previous Thread :: Next Thread 
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
09 Jun 2013 10:15 PM


Player,Trigger = script.Parent.Player,script.Parent.Trigger

Trigger.OnClick:connect(function(obj)
if (Player.Value and Player.Value.Parent) then return end

local plr = game.Players:GetPlayerFromCharacter(obj.Parent)
if (not plr) then return end

if (plr:FindFirstChild("RecentBinoc")) then return end
Player.Value = plr

local Control = script.Control:Clone()

wait()

Control.Parent = plr.Backpack
Control.Binoculars.Value = script.Parent
end)
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 10:18 PM
What exactly, do you want?
Report Abuse
Ozzypig is not online. Ozzypig
Joined: 27 Mar 2008
Total Posts: 4906
09 Jun 2013 10:19 PM
What about it?
Report Abuse
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
09 Jun 2013 10:23 PM
It won't work.
Report Abuse
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
09 Jun 2013 10:29 PM
Bump
Report Abuse
farmerman1379 is not online. farmerman1379
Joined: 22 Jan 2010
Total Posts: 423
09 Jun 2013 10:32 PM
Can you give us an error?
Report Abuse
geoglory is not online. geoglory
Joined: 02 Apr 2013
Total Posts: 1718
09 Jun 2013 10:34 PM
whats that?

~tiny plant head~
Report Abuse
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
09 Jun 2013 10:35 PM
The OnClick() doesn't work
Report Abuse
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
09 Jun 2013 10:47 PM
Bump
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
09 Jun 2013 10:47 PM
you need a clickdetector


so like


trigger.ClickDetector.MouseClick:connect(function(onclick)
Report Abuse
froggodude is not online. froggodude
Joined: 22 Sep 2012
Total Posts: 1638
09 Jun 2013 10:49 PM
I think if your trigger is a ClickDetector, then you may need to use: trigger.MouseClick:connect(function()
instead of OnClick()
Report Abuse
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
09 Jun 2013 10:54 PM
You're right but it still doesn't work.
Report Abuse
froggodude is not online. froggodude
Joined: 22 Sep 2012
Total Posts: 1638
09 Jun 2013 10:58 PM
Error?
Report Abuse
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
09 Jun 2013 10:59 PM
Anybody know how to fix it? I tried several different things but it doesn't work. I put the script.Parent.MouseButton1Click:connect(onClick) at the end and it still doesn't work.
Report Abuse
froggodude is not online. froggodude
Joined: 22 Sep 2012
Total Posts: 1638
09 Jun 2013 11:01 PM
Is your trigger a clickdetector or a textbutton?
Report Abuse
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
09 Jun 2013 11:02 PM
ClickDetector
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
09 Jun 2013 11:03 PM
you put this at the stop


trigger.MouseClick:connect(function(onclick)
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
09 Jun 2013 11:04 PM
What's the output?
Report Abuse
froggodude is not online. froggodude
Joined: 22 Sep 2012
Total Posts: 1638
09 Jun 2013 11:06 PM
It doesn't look like you have called your click function.

If so, then put this at the end of it:

trigger.MouseClick:connect(onClicked)
Report Abuse
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
09 Jun 2013 11:08 PM
Still doesn't work
Report Abuse
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
09 Jun 2013 11:10 PM
Every time I try to post the Output it says "Unexpected Error". Roblox doesn't like output
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
09 Jun 2013 11:10 PM
give ur latest script
Report Abuse
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
09 Jun 2013 11:14 PM
Player,Trigger = script.Parent.Player,script.Parent.Trigger
function OnClick(mouse)

Trigger.MouseClick:connect(function(obj)
if (Player.Value and Player.Value.Parent) then return end

local plr = game.Players:GetPlayerFromCharacter(obj.Parent)
if (not plr) then return end

if (plr:FindFirstChild("RecentBinoc")) then return end
Player.Value = plr

local Control = script.Control:Clone()

wait()

Control.Parent = plr.Backpack
Control.Binoculars.Value = script.Parent
trigger.MouseClick:connect(onClicked)
end)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
09 Jun 2013 11:15 PM
Player,Trigger = script.Parent.Player,script.Parent.Trigger

Trigger.MouseClick:connect(function(obj)
if (Player.Value and Player.Value.Parent) then return end

local plr = game.Players:GetPlayerFromCharacter(obj.Parent)
if (not plr) then return end

if (plr:FindFirstChild("RecentBinoc")) then return end
Player.Value = plr

local Control = script.Control:Clone()

wait()

Control.Parent = plr.Backpack
Control.Binoculars.Value = script.Parent
end)
Report Abuse
froggodude is not online. froggodude
Joined: 22 Sep 2012
Total Posts: 1638
09 Jun 2013 11:16 PM
put "end)" before your function call.
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