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

How do I make it so it switches teams when you join if a gamepass is owned?

So far I'ved used

game.Players.PlayerAdded:connect(function(plr) if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr, 13086230) then game.Players[plr.Name].TeamColor = BrickColor.new("Really blue") print("Player owns the gamepass!") else print("Player does not own the gamepass!") end end)

but even though I own it it says "Player does not own gamepass", I am new to scripting, please help!

1 answer

✓ Accepted answer

The issue here is that you used PlayerOwnsAssest instead of UserOwnsGamePassAsync. Also UserOwnsGamePassAsync requires the player's id, not the player. This is why it's useful to define your services as a constant so you can see the functions for it, instead of indexing it on one line.

local MPS = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(plr)
	if MPS:UserOwnsGamePassAsync(plr.UserId,13086230) then 
		game.Players[plr.Name].TeamColor = BrickColor.new("Really blue")
		print("Player owns the gamepass!")
	else
		print("Player does not own the gamepass!")
	end
end)

1 comment

0

Thank you so MUCH! It works!

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