Gamepass not working

  1. What do you want to achieve?

If the player has the gamepass, I want the player to be able to claim the plot.

  1. What is the issue?

When the player owns the gamepass, it still does not let them claim the plot.

When the player owns the gamepass, the building GUI is enabled; however, they’re unable to claim the building plot.

This is what it’s supposed to do/look like after you claim the plot:

  1. What solutions have you tried so far?

I’ve tried googling videos online and searching the dev forum but I haven’t found anything able to help!


PlotClaim Script

Workspace:
Screen Shot 2023-04-06 at 10.11.26 AM

Script:

local gamePassId = 123456

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if plr and script.Parent.Parent.PlotClaim.Value == false and 
			script.Parent.Parent.PlotClaimed.Value == false and
			plr.MembershipType == Enum.MembershipType.Premium or 
			plr.Name == "Auevi" or plr.Name == "Vinnxa" or plr:HasGamePass(gamePassId) then
			local PlotClaimed = plr.PlotClaimed
			PlotClaimed.Value = true
			script.Parent.Parent.PlayerName.Value = tostring(plr.Name)
			script.Parent.Parent.PlayerNamePart.SurfaceGui.PlayerNameLabel.Text = tostring(plr.Name) .. "'s House"
		end
	end
end)

Enabling GUI Script

This script works, but I wanted to include it in the post.

Workspace:

Screen Shot 2023-04-06 at 10.08.42 AM

Script:

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local gamePassID = 66410878  -- Change this to your game pass ID

local function onPlayerAdded(player)

	local hasPass = false

	-- Check if the player already owns the game pass
	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
	end)

	-- If there's an error, issue a warning and exit the function
	if not success then
		warn("Error while checking if player has pass: " .. tostring(message))
		return
	end

	if hasPass == true then
		print(player.Name .. " owns the game pass with ID " .. gamePassID)
		game.StarterGui.InventoryGui.Enabled = true
		game:GetService("BadgeService"):AwardBadge(player.UserId, 2130978482)
		-- Assign this player the ability or bonus related to the game pass
		--
		print(player.Name .. " BuildGUI enabled " .. gamePassID)
	end
end

-- Connect "PlayerAdded" events to the "onPlayerAdded()" function
Players.PlayerAdded:Connect(onPlayerAdded)

Thank you so much and let me know if you need more information! :heart:

Maybe try this?

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local gamePassID = 66410878  -- Change this to your game pass ID

local function onPlayerAdded(player)

	local hasPass = false

	-- Check if the player already owns the game pass
	local success, message = pcall(function()
		if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID) then
			hasPass = true
		end
	end)

	-- If there's an error, issue a warning and exit the function
	if not success then
		warn("Error while checking if player has pass: " .. tostring(message))
		return
	end

	if hasPass == true then
		print(player.Name .. " owns the game pass with ID " .. gamePassID)
		game.StarterGui.InventoryGui.Enabled = true
		game:GetService("BadgeService"):AwardBadge(player.UserId, 2130978482)
		-- Assign this player the ability or bonus related to the game pass
		--
		print(player.Name .. " BuildGUI enabled " .. gamePassID)
	end
end

-- Connect "PlayerAdded" events to the "onPlayerAdded()" function
Players.PlayerAdded:Connect(onPlayerAdded)
1 Like

Thank you so much!!! It actually turned out to be a few issues. :sweat_smile:

  1. I didn’t list the conditions properly in the ClaimPlot Script.

  2. The enableGUI script also wasn’t working either (which I didn’t know); however the script you provided worked!!

Thank you again :heart:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.