Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Not Changing Leaderstats and Text Value if Gamepass?

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

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!

2 comments

0

Doesnt work

0

What error are you getting?

This discussion is preserved as it was. New answers, comments, and votes are closed.