So, I am trying to make it so when you click on a part, you must wait a number which is an intvalue which is a child of boolvalue which is a child of a player in order to click it again.
When you click another part, that value is supposed to go down, so can click faster.
This is the script that I used in the part that you click again and again.
1 | game.Players.PlayerAdded:Connect( function (plr) |
2 | local buttonbutton = 5 |
3 | local buttonLvlTrack = Instance.new( "BoolValue" , plr) |
4 | buttonLvlTrack.Name = "ButtonLvl" |
5 | buttonLvlTrack.Value = buttonbutton |
6 | local buttonlvl = Instance.new( "IntValue" ,buttonLvlTrack) |
7 | buttonlvl.Name = "level" |
8 | buttonlvl.Value = buttonbutton |
end)
And this is the script that I used in the thing that’s supposed to reduce the time you are supposed to wait.
1 | local buy = script.Parent |
2 | local clickDetector = script.Parent:WaitForChild( "ClickDetector" ) |
3 |
4 |
5 | clickDetector.MouseClick:Connect( function (plr) |
6 | local bt = plr:WaitForChild( "ButtonLvl" ):FindFirstChild( "level" ).Value |
7 | bt = bt - 1 |
end)
There are no errors, warnings, or anything, but still won’t work. Please help ^^
Use :GetService() to retrieve the Players Service
Define the Parent of each Instance outside of the Instance.new() function
You are defining bt as a reference value, so when you write bt = bt - 1 you are not changing the actual value, you are merely writing that the local variable bt is now 1 less than it was before. Instead, you can make bt be the level instance, and then for the math, state the Value Property directly in order to change it.
01 | game:GetService( "Players" ).PlayerAdded:Connect( function (plr) |
02 | local buttonbutton = 5 |
03 | local buttonLvlTrack = Instance.new( "BoolValue" ) |
04 | buttonLvlTrack.Name = "ButtonLvl" |
05 | buttonLvlTrack.Value = buttonbutton |
06 | buttonLvlTrack.Parent = plr |
07 | |
08 | local buttonlvl = Instance.new( "IntValue" ) |
09 | buttonlvl.Name = "level" |
10 | buttonlvl.Value = buttonbutton |
11 | buttonlvl.Parent = buttonLvlTrack |
12 | end ) |
13 |
14 | local buy = script.Parent |
15 | local clickDetector = buy:WaitForChild( "ClickDetector" ) |
16 |
17 | clickDetector.MouseClick:Connect( function (plr) |
18 | local bt = plr:WaitForChild( "ButtonLvl" ):FindFirstChild( "level" ) |
19 | bt.Value = bt.Value - 1 |
20 | end ) |