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: Can't seem to figure this out

Previous Thread :: Next Thread 
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
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 is not online. 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 is not online. 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
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
04 Aug 2012 11:15 PM
@human
the second one didn't work
Report Abuse
human is not online. human
Joined: 06 May 2007
Total Posts: 2765
04 Aug 2012 11:16 PM
output?
Report Abuse
adark is not online. 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 is not online. 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 is not online. 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
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
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 is not online. 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 is not online. 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
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
04 Aug 2012 11:36 PM
@ninjaknight101 lolnoob
Report Abuse
adark is not online. 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
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