Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Gamepass script not working?

This game pass script is connected to a GUI text button and the function of it is to change the players profession to Bank Staff if they have the game pass and it seems not to change my profession and yes it is in a LocalScript! If someone could help fix the script and explain what I did wrong that would be helpful.

local player = game:GetService("Players").LocalPlayer
local GamePassService = game:GetService('GamePassService')
local GamePassId = 416231639


function Good()
	if GamePassService:PlayerHasPass(player, GamePassId) then
	player.leaderstats.WantedLevel.Value = 0
	player.leaderstats.Profession.Value = "Bank Staff"
	script.Parent.Parent.Parent.AppliedGood.Visible = true
	script.Parent.Parent.Visible = false
  else script.Parent.Parent.Parent.AppliedError.Visible = true
	script.Parent.Parent.Visible = false
  end
 end

script.Parent.MouseButton1Down:connect(Good)

3 comments

2

I'd avoid doing this in a LocalScript.

0

Alright I tried still dont work

0

gamepassservice is depreciated. use marketplaceservice. http://wiki.roblox.com/index.php?title=API:Class/MarketplaceService/PlayerOwnsAsset

1 answer

✓ Accepted answer
function Good()
if game.MarketplaceService:PlayerOwnsAsset(player,GamePassId) then
player.leaderstats.WantedLevel.Value = 0
    player.leaderstats.Profession.Value = "Bank Staff"
    script.Parent.Parent.Parent.AppliedGood.Visible = true
    script.Parent.Parent.Visible = false
  else 
script.Parent.Parent.Parent.AppliedError.Visible = true
    script.Parent.Parent.Visible = false
  end
 end

This discussion is preserved as it was. New answers, comments, and votes are closed.