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

How do I whitelist my friend on my gamepasss script?

So. I am kinda making a kind of fnaf game. I've attempted this before it has not even worked with Names / ID's, Please fix. Its HardMode BTW

local debounce = false
local Clicked = false
local MarketplaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local hasPass = false

local Bypassed = {
	"Panda_Scopez12";
}

gamePassID = 7415466

script.Parent.MouseButton1Click:Connect(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
	if Bypassed == player.Name then
		wait(0.2)
		hasPass = true
	end
	if hasPass == true and debounce == false and Clicked == false then
		debounce = true
		Clicked = true
		script.Parent.Text = "Hard Mode: On"
		script.Parent.Parent.Parent.HardMode.Value = true
	wait(0.5)
	debounce = false
	elseif hasPass == true and debounce == false and Clicked == true then
		debounce = true
		Clicked = false
		script.Parent.Text = "Hard Mode: Off"
		script.Parent.Parent.Parent.HardMode.Value = false		
	elseif hasPass == false and debounce == false then
		MarketplaceService:PromptGamePassPurchase(player, gamePassID)
		script.Parent.Text = "ACCESS DENIED"
		wait(1)
		script.Parent.Text = "Hard Mode: Off"
		script.Parent.Parent.Parent.HardMode.Value = false
	wait(0.5)
	debounce = false		
	end
end)

1 answer

✓ Accepted answer

You are attempting to compare a table value with a string value, do this

local debounce = false
local Clicked = false
local MarketplaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local hasPass = false

local Bypassed = {
    "Panda_Scopez12";
}

gamePassID = 7415466

script.Parent.MouseButton1Click:Connect(function()
    hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
   for i,v in pairs(Bypassed) do
if v == player.Name then
hasPass = true
break

end
end
    if hasPass == true and debounce == false and Clicked == false then
        debounce = true
        Clicked = true
        script.Parent.Text = "Hard Mode: On"
        script.Parent.Parent.Parent.HardMode.Value = true
    wait(0.5)
    debounce = false
    elseif hasPass == true and debounce == false and Clicked == true then
        debounce = true
        Clicked = false
        script.Parent.Text = "Hard Mode: Off"
        script.Parent.Parent.Parent.HardMode.Value = false      
    elseif hasPass == false and debounce == false then
        MarketplaceService:PromptGamePassPurchase(player, gamePassID)
        script.Parent.Text = "ACCESS DENIED"
        wait(1)
        script.Parent.Text = "Hard Mode: Off"
        script.Parent.Parent.Parent.HardMode.Value = false
    wait(0.5)
    debounce = false        
    end
end)

If this helped mark this as the answer :D

2 comments

0

darn was just about to make a answer

0

Thanks man. Works like I wanted it to.

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