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

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

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?

4 comments

0

Going to need more info, can you provide a screenshot of where the script is for both of them? Just send a link

0

Ok i'll edit

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?

0

No errors are shown in any of the scripts. It's meant to show a gui only if a player owns a gamepass

1 answer

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)

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