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

Is it possible to make a gamepass that is given to specific players?

Im making a 2x selling gamepass for a simulator im creating and I want to give the gamepass to my friends that helped create it. This is the script im using and i want to know if i could change the script so instead of it being used for players with the gamepass its for specific players or so i can give them the gamepass. btw the gamepass id is on a IntValue attached to the script

game.Players.PlayerAdded:Connect(function(player)
	
	local marketservice = game:GetService("MarketplaceService")
	
	local can = true
	repeat wait() until player:FindFirstChild("leaderstats")
	local leader = player:FindFirstChild("leaderstats")
	if leader then
	repeat wait() until leader:FindFirstChild(script:WaitForChild("Currency").Value)
	local currency = leader:FindFirstChild(script:WaitForChild("Currency").Value)
		if currency then
			local folder = Instance.new("Folder",player)
			folder.Name = "2xGamepass"
			local oldmoney = Instance.new("IntValue",folder)
			oldmoney.Name = "OldMoney"
			oldmoney.Value = currency.Value
			local give2x = Instance.new("IntValue",folder)
			give2x.Name = "Give2x"
			give2x.Value = 0
			
			currency.Changed:Connect(function()
				if marketservice:UserOwnsGamePassAsync(player.UserId, script:WaitForChild("GamepassId").Value) then
				
					
				if can == true then
					can = false
				if currency.Value > oldmoney.Value then
				give2x.Value = currency.Value - oldmoney.Value
			
				currency.Value = currency.Value + give2x.Value
				
				oldmoney.Value = currency.Value
					can = true
					else
						
							oldmoney.Value = currency.Value
							can = true
						
						
				end
					
				end
				else
					oldmoney.Value = currency.Value
				end
			end)
			
		end
	end
end)

1 answer

✓ Accepted answer

Add an override with an UserId (or you could use usernames but then if they changed there username they will lose it) if marketservice:UserOwnsGamePassAsync(player.UserId, script:WaitForChild("GamepassId").Value) then replaced with if marketservice:UserOwnsGamePassAsync(player.UserId, script:WaitForChild("GamepassId").Value) or player.UserId == freeplayerid then

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