Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

[URGENT] Script Doesn't Multiply or Convert Leaderstats?

Asked by
Rynappel 212 Moderation Voter
5 years ago

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!

01local debounce = true
02 
03script.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)
View all 27 lines...

Things to remeber, - It is a ServerScript - The Scripts parent is a Part

1 answer

Log in to vote
1
Answered by
Gojinhan 353 Moderation Voter
5 years ago
Edited 5 years ago

dude scripting helpers makes the formatting for that atrocious.. I can't read it lmao i'll try anyway tho

01local debounce = false -- converted this to false true debounces get annoying lol
02 
03script.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)
View all 27 lines...

Everything here seems fine besides a few things :P

Tried it in my own game with different leaderstat values and it worked fine.

0
It doesnt work, even if I dont own the gamepass, it stil multiplys it Rynappel 212 — 5y
0
Nvm it worked TYSM Rynappel 212 — 5y
Ad

Answer this question