Halo for only who have gamepass

I make script that you can only get if you own the gamepass but when i test its not working the locked gui is still visible …

local player = game.Players.LocalPlayer

local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,11586496)-- put your gamepass Id here

local haloGui = script.Parent:WaitForChild("Halo")

local haloFrame = haloGui.MainFrame:WaitForChild("Blue Frame")

local locked = haloFrame:WaitForChild("Locker")

local equip = haloFrame:WaitForChild("Equipped")

local unequip = haloFrame:WaitForChild("Unequipped")

local equipped = haloFrame:WaitForChild("Equipped")

local unequipped = haloFrame:WaitForChild("Unequipped")

haloFrame.Visible = false

if ownsGamepass then

haloFrame.Visible = true

locked.Visible = false

end

if not ownsGamepass then

locked.Visible = true

haloFrame.Visible = true

equip.Visible = false

unequip.Visible = false

equipped.Visible = false

unequipped.Visible = false

end
1 Like

Your script will only run one time, which is when the user first joins the game. If you buy the gamepass mid-game, it won’t update the locked gui. Try rejoining the game after you have purchased the gamepass.

but i own the gamepass before i make that script

Are there any errors in the dev console?

i dont see anything says error

What exactly are you trying to give the player who owns the gamepass? A gear? A Gui it looks like? Please elaborate if you could!

Im trying to make that if players owns the gamepass the gui or frame of locker will be false and if not its true so they cant equip the gear that covering the equip.

Well…I think I may have come up with a script for you, but I just need one question.

Could you tell me which guis you want to be visible when the user has the gamepass? And which ones do you want not to visible? Thank you.

Your code says

if not ownsPass then 
haloFrame.Visible = true

Wouldn’t you set it to false?

it’s true. because it is on true. Shouldn’t that be false?

That should be false. correct.

Is it on a local script? I think to make stuff visible or not visible it needs to be on a local script

What you should try is running a script in ServerScriptService that checks if the player owns the gamepass. If so, it uses a RemoteEvent (which is automatically created through script, so dont add one yourself) to fire to the client of the person who has the gamepass.

-- Script Inside ServerScriptService

local MarketPlaceService = game:GetService("MarketplaceService")

local GamePassID = 11586496

local EnableHaloFrame = Instance.new("RemoteEvent")
EnableHaloFrame.Name = "EnableHaloFrame"
EnableHaloFrame.Parent = game.ReplicatedStorage

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamePassID) then
			EnableHaloFrame:FireClient(Player)
		end
	end)
end)

Then, you’ll want to create a script in StarterGui, which users that RemoteEvent to trigger the Guis to enable.

-- LocalScript Inisde StarterGui

local Remote = game.ReplicatedStorage:FindFirstChild("EnableHaloFrame")

local haloGui = script.Parent:WaitForChild("Halo")
local haloFrame = haloGui.MainFrame:WaitForChild("Blue Frame")
local locked = haloFrame:WaitForChild("Locker")
local equip = haloFrame:WaitForChild("Equipped")
local unequip = haloFrame:WaitForChild("Unequipped")
local equipped = haloFrame:WaitForChild("Equipped")
local unequipped = haloFrame:WaitForChild("Unequipped")

Remote.OnClientEvent:Connect(function() -- Note: Some of the true/falses' may be incorrect, so do feel free to change them to your liking.
    haloFrame.Visible = true
    locked.Visible = false
    equip.Visible = true
    unequip.Visible = true
    equipped.Visible = true
    unequipped.Visible = true
end)

Hope this can help! Let me know if you have any questions.