|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 14 Jul 2017 11:00 PM |
| but that doesnt give exp tho |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|