Hello, I am developing a game and there is a wall which you can only pass if you have bought a gamepass. The problem is that i tested it out with a friend but the wall was not there even tho he didnt purchase the game pass.
I've put a local script into the wall and it's
script.Parent.Touched:Connect(function(hit) game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 18801304) end)
I've also put a script into serverscriptservice which does :
local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local conveyorGamepassID = 18801304 game.Players.PlayerAdded:Connect(function(player) local success, message = pcall(function() hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, conveyorGamepassID) end) if hasPass then print("player has the gamepass") game.Workspace.MainBuild.MainConveyor.ConveyorBorder.CanCollide = false end end) local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess) if purchaseSuccess == true and purchasedPassID == conveyorGamepassID then print(player.Name .. " purchased the game pass!") game.Workspace.MainBuild.MainConveyor.ConveyorBorder.CanCollide = false end end MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)
Could anyone please help?
This is because if the player has the pass, its still a serverside, so its not for the client/player, but instead for everyone.
make a Local Script:
--PUT THIS SCRIPT UNDER STARTERGUI-- local MarketplaceService = game:GetService("MarketplaceService") local Player = game.Players.LocalPlayer local doorPart = game.Workspace.MainBuild.MainConveyor.ConveyorBorder local gamepassId = 18801304 if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamepassId) then print("Player owns pass.") doorPart.CanCollide = false else print("Player does not own pass.") doorPart.CanCollide = true end