Hello, I have this script here, which when you touch the part, it is supposed to convert the ingame leaderstats, "Jump" into "Bills" so say you have 10 Jumpand you touch the part, its supposed to turn that Jump into Bills, so now you would have 0 jump and 10 bills. And if you owned a gamepass, then if you had 10 jump, it was supposed to turn it into 20 bills instead of 10. It doesnt work though and i have failed to figure out why. Could ANYBODY please help me with this, it is quite urgent, Thank you merry christmas!
01 | local debounce = true |
02 |
03 | script.Parent.Touched:Connect( function (partThatTouched) |
04 | local humanoid = partThatTouched.Parent:FindFirstChildWhichIsA( "Humanoid" ) |
05 | if humanoid then |
06 | local player = game.Players:FindFirstChild(partThatTouched.Parent.Name) |
07 | local PlrStatsJump = player.leaderstats:FindFirstChild( "Jump" ) |
08 | local PlrStatsBills = player.leaderstats:FindFirstChild( "Bills" ) |
09 | if debounce then |
10 | if game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(partThatTouched, 7549267 ) then |
11 | debounce = false |
12 | PlrStatsBills.Value = PlrStatsBills.Value + PlrStatsJump.Value * 2 |
13 | wait() |
14 | PlrStatsJump.Value = 0 |
15 | wait ( 2 ) |
Things to remeber, - It is a ServerScript - The Scripts parent is a Part
dude scripting helpers makes the formatting for that atrocious.. I can't read it lmao i'll try anyway tho
01 | local debounce = false -- converted this to false true debounces get annoying lol |
02 |
03 | script.Parent.Touched:Connect( function (partThatTouched) |
04 | -- changed the if below to not throw an error if it doesnt find it |
05 | if partThatTouched.Parent:FindFirstChildWhichIsA( "Humanoid" ) then |
06 | local player = game.Players:FindFirstChild(partThatTouched.Parent.Name) |
07 | local PlrStatsJump = player.leaderstats:FindFirstChild( "Jump" ) |
08 | local PlrStatsBills = player.leaderstats:FindFirstChild( "Bills" ) |
09 | if not debounce and PlrStatsJump and PlrStatsBills then |
10 | if game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(player.userId, 7549267 ) then -- seemed like u wer using that incorrecetly |
11 | debounce = true |
12 | PlrStatsBills.Value = PlrStatsBills.Value + PlrStatsJump.Value * 2 |
13 | wait() |
14 | PlrStatsJump.Value = 0 |
15 | wait ( 2 ) |
Everything here seems fine besides a few things :P
Tried it in my own game with different leaderstat values and it worked fine.