New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
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 5 days 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 4 days 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 PurpleProgram 153 — 4d
0
What error are you getting? TheLastHabanero 123 — 4d
Ad

Answer this question