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!
local debounce = true script.Parent.Touched:Connect(function(partThatTouched) local humanoid = partThatTouched.Parent:FindFirstChildWhichIsA("Humanoid") if humanoid then local player = game.Players:FindFirstChild(partThatTouched.Parent.Name) local PlrStatsJump = player.leaderstats:FindFirstChild("Jump") local PlrStatsBills = player.leaderstats:FindFirstChild("Bills") if debounce then if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(partThatTouched, 7549267) then debounce = false PlrStatsBills.Value = PlrStatsBills.Value + PlrStatsJump.Value * 2 wait() PlrStatsJump.Value = 0 wait (2) debounce = true else debounce = false PlrStatsBills.Value = PlrStatsBills.Value + PlrStatsJump.Value wait() PlrStatsJump.Value = 0 wait (2) debounce = true end end end end)
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
local debounce = false -- converted this to false true debounces get annoying lol script.Parent.Touched:Connect(function(partThatTouched) -- changed the if below to not throw an error if it doesnt find it if partThatTouched.Parent:FindFirstChildWhichIsA("Humanoid") then local player = game.Players:FindFirstChild(partThatTouched.Parent.Name) local PlrStatsJump = player.leaderstats:FindFirstChild("Jump") local PlrStatsBills = player.leaderstats:FindFirstChild("Bills") if not debounce and PlrStatsJump and PlrStatsBills then if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userId, 7549267) then -- seemed like u wer using that incorrecetly debounce = true PlrStatsBills.Value = PlrStatsBills.Value + PlrStatsJump.Value * 2 wait() PlrStatsJump.Value = 0 wait (2) debounce = false else debounce = true PlrStatsBills.Value = PlrStatsBills.Value + PlrStatsJump.Value wait() PlrStatsJump.Value = 0 wait (2) debounce = false end end end end)
Everything here seems fine besides a few things :P
Tried it in my own game with different leaderstat values and it worked fine.