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

Why do I have 1 script that works and an identical one that doesn't?

Asked by 2 years ago
Edited 2 years ago

Help! I have 2 scripts that are exactly the same

Script 1

local id = game.ReplicatedStorage.Values.GamePassID.Value

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
    if purchased and ido == id then

        script.Parent.Visible = true
        print("showing")
    end
end)

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then

            script.Parent.Visible = true
        end
    end)
end)

This one works but then script 2, which is almost identical except for the path above ( the local id = ...) doesn't work!

local id = game.ReplicatedStorage.Values.JumpPassID.Value

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
    if purchased and ido == id then

        script.Parent.Visible = true
    end
end)

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then

            script.Parent.Visible = true
        end
    end)
end)

Here's a pic of the path :file:///C:/Users/stefa/Videos/Screenshot%202022-03-17%20152515.png

Why?

0
Going to need more info, can you provide a screenshot of where the script is for both of them? Just send a link User#31501 0 — 2y
0
Ok i'll edit juventuuss 0 — 2y
0
You'll probably need to provide some more information. What do you mean by it doesn't work? Is there any error that gets shown? What is the script expected to do and what isn't working? bbissell 346 — 2y
0
No errors are shown in any of the scripts. It's meant to show a gui only if a player owns a gamepass juventuuss 0 — 2y

1 answer

Log in to vote
-1
Answered by 2 years ago
local id = game.ReplicatedStorage.Values.JumpPassID.Value 

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
    if purchased and ido == id then

        script.Parent.Visible = true --Make sure your paths are correct and not client sided
    end
end)

Ad

Answer this question