Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

Not Changing Leaderstats and Text Value if Gamepass?

Asked by
Rynappel 212 Moderation Voter
6 months ago

I have a local script located in a textlabel and its supposed to change the text if the player has a gamepass then its supposed to say 0/Infinite (the zero is the value of Jump) if they have the gamepass and if they dont have a gamepass then it will show 0/0 (the zeros is the value of Jump and Pack) how ever it doesnt work can somebody help me

local id = 7746555
local player = game.Players.LocalPlayer
local pack = player:WaitForChild("leaderstats").Pack
local jump = player:WaitForChild("leaderstats").Jump

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
    if purchased and ido == id then
        if plr.Character then
            script.Parent.Text = jump.Value.."/Infinite"
        end
    end
end)

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id) then
            script.Parent.Text = jump.Value.."/Infinite"
        else
            script.Parent.Text = jump.Value.."/"..pack.Value
        end
    end)
end)

1 answer

Log in to vote
0
Answered by
haba_nero 311 Moderation Voter
6 months ago

Simple! Use FindFirstChild() and tostring()

wait(5)
local id = 7746555
local player = game.Players.LocalPlayer
local pack = player.leaderstats:FindFirstChild("Pack")
local jump = player.leaderstats:FindFirstChild("Jump")

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
    if purchased and ido == id then
        if plr.Character then
            script.Parent.Text = tostring(jump.Value.."/Infinite")
        end
    end
end)

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id) then
            script.Parent.Text = tostring(jump.Value.."/Infinite")
        else
            script.Parent.Text = tostring(jump.Value.."/"..pack.Value)
        end
    end)
end)

Hope this helps!

0
Doesnt work Rynappel 212 — 6mo
0
What error are you getting? haba_nero 311 — 6mo
Ad

Answer this question