Value not changing when player owns gamepass

print("Test1")

local marketPlaceService = game:GetService("MarketplaceService")
local armouryGamepassID = 15200406
local carDealershipGamepassID = 15200942

local players = game:GetService("Players")
local player = players.LocalPlayer

local armoury1Door = workspace:WaitForChild("Englewood.GeneralBuildings")["Englewood.Armory1"].WorkingDoor.Door
local armoury1Value = armoury1Door.DoorScript.CanOpen.Value

local armoury2Door = workspace:WaitForChild("Englewood.GeneralBuildings")["Englewood.Armory2"].WorkingDoor.Door
local armoury2Value = armoury2Door.DoorScript.CanOpen.Value


print("Test")

-- Armoury gamepass

marketPlaceService:PromptGamePassPurchase(player, armouryGamepassID)

if marketPlaceService:UserOwnsGamePassAsync(player.UserId, armouryGamepassID) then
	armoury1Value = true
	armoury2Door = true
	print(player.Name .. " own's gamepass")
else
	print(player.Name .. " doesn't own gamepass")
end

-- Car dealership gamepass

local dealershipDoor = workspace:WaitForChild("EGWD").Model.WorkingDoor.Door
local dealershipValue = dealershipDoor.DoorScript.CanOpen.Value

if marketPlaceService:UserOwnsGamePassAsync(player.UserId, carDealershipGamepassID) then
	dealershipValue = true
	print(player.Name .. " own's gamepass")
else
	print(player.Name .. " doesn't own gamepass")
end

Value does not change if they own the gamepass

print("Test1")

local marketPlaceService = game:GetService("MarketplaceService")
local armouryGamepassID = 15200406
local carDealershipGamepassID = 15200942

local players = game:GetService("Players")
local player = players.LocalPlayer

local armoury1Door = workspace:WaitForChild("Englewood.GeneralBuildings")["Englewood.Armory1"].WorkingDoor.Door
local armoury1Value = armoury1Door.DoorScript.CanOpen

local armoury2Door = workspace:WaitForChild("Englewood.GeneralBuildings")["Englewood.Armory2"].WorkingDoor.Door
local armoury2Value = armoury2Door.DoorScript.CanOpen


print("Test")

-- Armoury gamepass

marketPlaceService:PromptGamePassPurchase(player, armouryGamepassID)

if marketPlaceService:UserOwnsGamePassAsync(player.UserId, armouryGamepassID) then
	armoury1Value.Value = true
	armoury2Door.Value = true
	print(player.Name .. " own's gamepass")
else
	print(player.Name .. " doesn't own gamepass")
end

-- Car dealership gamepass

local dealershipDoor = workspace:WaitForChild("EGWD").Model.WorkingDoor.Door
local dealershipValue = dealershipDoor.DoorScript.CanOpen

if marketPlaceService:UserOwnsGamePassAsync(player.UserId, carDealershipGamepassID) then
	dealershipValue.Value = true
	print(player.Name .. " own's gamepass")
else
	print(player.Name .. " doesn't own gamepass")
end

Have you tried this? Maybe don’t have variables that refer to the value, but maybe to the object, and then when changing values use the variable and refer to its value there.

This rarely solves the problem but worked for me once or twice.

1 Like

Suprisingly, that actually worked. Thank you.