Need some help with boolvalue

Ive been working on a tower defense game and im tryna add a gamepass feature for the shop. Im trying to use a boolvalue for the true and false reason of it obviously but for some reason it never shows up in the shop. Been stuck with it the last few days.

Script where the bool value is created

Players.PlayerAdded:Connect(function(player)

local Even = Instance.new("BoolValue")
Even.Name = "Even"
Even.Value = false
Even.Parent = player

end

Heres the shop module script

local TowerShop = {	
        ["Blue Robloxian"] = {
		["Name"] = "Blue Robloxian",
		["ImageAsset"] = "rbxassetid://11624666096" ,
		["Price"] = 1 ,
		["Description"] = "    ",
	    ["Event"] = --True if player owns gamepass if not false 
 }
return TowerShop

The function where the shop loads

function updateItems()
points.Text = "Points : " .. playerData.Points
limit.Text = #playerData.SelectedTowers .. "/4"

for i, tower in pairs(towers) do
	
	local oldButton = gui.Frame.Center1.List:FindFirstChild(tower.Name)
	if oldButton then
		oldButton:Destroy()
	end
	local newButton = itemsFrame:Clone()
	newButton.Name = tower.Name
	newButton.TowerName.Text = tower.Name
	newButton.Price.Text = tower.Price .. " Points"
	newButton.Image.Image = tower.ImageAsset
	newButton.Desc.Text = tower.Description
	newButton.Visible = tower.Event
	newButton.LayoutOrder = tower.Price
	newButton.Parent = gui.Frame.Center1.List
	
	local status = getItemStatus(tower.Name)
	if status == "For Sale" then
		newButton.Status.Text = "PURCHASE"
	elseif status == "Equipped" then
		newButton.Status.Text = "EQUIPPED"
		newButton.Price.Visible = false
	else 
		newButton.Status.Text = "EQUIP"
		newButton.Price.Visible = false
	end
	newButton.Status.Activated:Connect(function()
		interactItem(tower.Name)
	end)

end
end

I don’t get why you’re setting the boolvalue to false when you can just do:

MarketplaceService:UserOwnsGamePassAsync(plr.UserId,gamepassid) --[[returns true or false
depending on if the plr owns the gamepass.]]

The issue is that the bool value is not being correctly checked. The bool value is not being passed into the shop data. To fix this, you need to add the bool value to the shop data in the shop module script. You can do this by adding the following line of code:

["Event"] = Even.Value,

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