|
| 04 Aug 2012 11:04 PM |
When someone clicks this brick if they have 200 cash then it should give them this Sprint tool. No output.
function onClicked() if game.Players.LocalPlayer.leaderstats.Cash.Value >= 0 then game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value - 200 Sprint = game.Lighting.Sprint:clone() Sprint.Parent = game.Players.LocalPlayer.StarterGear end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
|
|
| Report Abuse |
|
|
human
|
  |
| Joined: 06 May 2007 |
| Total Posts: 2765 |
|
|
| 04 Aug 2012 11:09 PM |
local player = game.Players.LocalPlayer local leaderstats = player.leaderstats.Cash
function onClicked() if leaderstats.Value >= 0 then leaderstats.Value == leaderstats.Cash.Value - 200 game.Lighting:findFirstChild("Sprint"):Clone().Parent = player.PlayerGui end end
script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
human
|
  |
| Joined: 06 May 2007 |
| Total Posts: 2765 |
|
|
| 04 Aug 2012 11:10 PM |
*edit
local player = game.Players.LocalPlayer local leaderstats = player.leaderstats.Cash
function onClicked() if leaderstats.Value >= 0 then leaderstats.Value == leaderstats.Value - 200 game.Lighting:findFirstChild("Sprint"):Clone().Parent = player.PlayerGui end end
script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2012 11:15 PM |
@human the second one didn't work |
|
|
| Report Abuse |
|
|
human
|
  |
| Joined: 06 May 2007 |
| Total Posts: 2765 |
|
| |
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 04 Aug 2012 11:21 PM |
Unless placed in a Local Part, there's no way to tell who clicked a ClickDetector. It's why they aren't used as often.
stravant made a pseudo-ClickDetector that could tell, and didn't change the cursor when moused over, but it would glitch out the mouse when it was used.
You're going to have to change this to use a Touched event, a Tool/HopperBin, or a GUI.
BTW, John, add the ability to tell who clicked a ClickDetector. :F |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 04 Aug 2012 11:30 PM |
Ignore my last post, I'm tired and apparently it wasn't advertised that you now *can* tell who clicked a ClickDetector. I also didn't notice that LocalScript.
Please feel free to direct mild "lolnoob" comments in my direction.
script.Parent.ClickDetector.MouseClick:connect(function(player) if player.leaderstats.Cash.Value < 200 then return; end player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 200; Game.Lighting.Sprint:Clone().Parent = player.StarterGear; end); |
|
|
| Report Abuse |
|
|
Xnite515
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 22763 |
|
|
| 04 Aug 2012 11:33 PM |
lolnoob in adark's direction --my script created bhe best scripter xnite515
is that rite |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2012 11:35 PM |
@adark. Umm, there is actually. The only argument passed in the ClickDetector function is WHO clicked it. -_-
Workspace.Part.ClickDetector.MouseClick:connect(function(playerWhoClicked) print("Part was clicked by: " .. playerWhoClicked.Name) end) |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 04 Aug 2012 11:35 PM |
@Xnite;
Please don't reply to serious forum threads unless you have something meaningful to add. |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 04 Aug 2012 11:35 PM |
@ninjaknight;
*points to join date* When ClickDetectors first came out, the didn't return anything. |
|
|
| Report Abuse |
|
|
| |
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 04 Aug 2012 11:38 PM |
| Don't hate on yourself, we're all tired. I said that in my post as a joke, because I had written out an essay of a response. :P |
|
|
| Report Abuse |
|
|