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 » Scripters
Home Search
 

Re: onClicked question

Previous Thread :: Next Thread 
PhantomBread is not online. PhantomBread
Joined: 05 Dec 2012
Total Posts: 236
14 Jul 2017 10:23 PM
so im trying to make a script that goes inside a tool that makes you do an animation and your exp goes up, however nothing is happening when I click. Am I doing anything wrong in the script below?

function click(playerWhoClicked)
game.Players.LocalPlayer.leaderstats.EXP.Value = game.Players.LocalPlayer.leaderstats.EXP.Value + 100
end

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

I just read some stuff off the wiki and made the script below. If you know how to fix this could you give me the fixed version and explain what I did wrong?


Report Abuse
PhantomBread is not online. PhantomBread
Joined: 05 Dec 2012
Total Posts: 236
14 Jul 2017 10:28 PM
bump. also the game is in FE so tell me if that might be the problem
Report Abuse
njesk12 is not online. njesk12
Joined: 21 Aug 2012
Total Posts: 65
14 Jul 2017 10:39 PM
If the click detector is in that tool then that's the problem. Click detectors work when you click on a part, not just for clicking all willy nilly. Therefore, what you should do instead is this:

local tool = script.Parent

tool.Activated:connect(function()
print 'Let's dance!'
end)

there you go! :D
Report Abuse
PhantomBread is not online. PhantomBread
Joined: 05 Dec 2012
Total Posts: 236
14 Jul 2017 11:00 PM
but that doesnt give exp tho
Report Abuse
Wizzoblox02 is online. Wizzoblox02
Joined: 29 Dec 2015
Total Posts: 101
14 Jul 2017 11:05 PM
njesk12 has the right idea. Using that and replacing a part of your script should make it look like this:

function ToolActivated(PlrWhoClicked)
game.Players.LocalPlayer.leaderstats.EXP.Value=game.Players.LocalPlayer.leaderstats.EXP.Value+100 -- Assuming these are the correct variables, this should add EXP to the player
end

script.Parent.Activated:connect(ToolActicated) -- Detects when a Player activates the tool
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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