- What do you want to achieve?
If the player has the gamepass, I want the player to be able to claim the plot.
- 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:
- 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:
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:
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!