The title is kinda click bait because other titles weren't working for some reason. About an hour ago I asked why my script wasn't working and so someone helped me out, but when I add a wait so I doesn't give me infinite amounts of cash. But it doesn't work. Any help?
01 | local leaderstats -- We need to get the player before we do anything. Leave blank for now. |
02 | local playersService = game:GetService "Players" |
03 | local debounce = false -- if you don't want it to spam "Raw Robloxs" add this. |
04 |
05 | script.Parent.Touched:Connect( function (part) |
06 | if not debounce and part.Parent.Name = = "Pick" then |
07 | local plr = playersService:GetPlayerFromCharacter(part.Parent.Parent) |
08 | if plr then -- make sure it's a player |
09 | debounce = true |
10 | leaderstats = plr:WaitForChild "leaderstats" |
11 | leaderstats [ "Raw Robloxs" ] .Value = leaderstats [ "Raw Robloxs" ] .Value + 5 |
12 | -- debounce = false -- Debounce reset logic can go here. Reset to false so the code can repeat. If you wish for it to not repeat, take this off and it can be a one time touch. |
13 | wait( 1 ) |
14 | end |
15 | end |
16 | end ) |
17 |
18 | script.Parent.TouchEnded:Connect( function (part) |
19 | debounce = false -- Debounce logic can go here if you want it to reset after it stops touching. |
20 | end ) |
01 | local leaderstats -- We need to get the player before we do anything. Leave blank for now. |
02 | local playersService = game:GetService "Players" |
03 | local debounce = false -- if you don't want it to spam "Raw Robloxs" add this. |
04 | local moneyToGive = 5 |
05 |
06 | script.Parent.Touched:Connect( function (part) |
07 | if not debounce and part.Parent.Name = = "Pick" then |
08 | local plr = playersService:GetPlayerFromCharacter(part.Parent.Parent) |
09 | if plr then -- make sure it's a player |
10 | debounce = true |
11 | leaderstats = plr:WaitForChild "leaderstats" |
12 | leaderstats [ "Raw Robloxs" ] .Value = leaderstats [ "Raw Robloxs" ] .Value + moneyToGive |
13 | -- debounce = false -- Debounce reset logic can go here. Reset to false so the code can |
14 | repeat . If you wish for it to not repeat , take this off and it can be a one time touch. |
15 | moneyToGive = 0 -- set to 0 so it will just give 0 cash. |