Hey, I ain’t that much of a scripter and youtube isn’t helping me so, I have to ask you guys, so, I need a script for a team button that is only available to gamepass owners, I already have the GUI ready I just need the script to make it gamepass only.
-- local script in button
local Player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.TeamChange:FireClient(Player)
end)
-- server script in server script service
local Teams = game:GetServie("Teams")
local Team1 = Instance.new("Team", Teams)
Team1.BrickColor = BrickColor.new("YourBrickColor")
Team1.Name = "YourTeamName"
game.ReplicatedStorage.TeamChange.OnClientEvent:Connect(function(player)
player.Team = Team
end)
Let me know if an error happens
Thank you, we are about to test it, i’ll inform you if it works or no.
Where do we put the gamepass ID?
what do you mean??? Are you ranking the player by seeing what rank they are in your group?
Well no, we want it to be like a button that teams you into an existing team but only people with the the selected gamepass can press it and get teamed.
local GamepassId = "Gamepassidhere"
local MarketplaceService= game:GetService("MarketplaceService")
if MarketplaceService:UserOwnsGamePassAsync(userId, GamepassId) then
--code here
end
Sorry for the late response, let me try it.
I am also having a similar situation, so I searched this up and tested this script. But it is getting confused with the “userId” part. It says “W001: Unknown Global”. I understand I am quite a bit late, but I am having a similar issue and I am wondering how to fix this. Should “userId” be a variable? Or what?
try
player.UserId
instead of
player.userId
oh noooo, the userid is supposed to be the players userid i put userId there just so you know to put the players user id
like this
local GamepassId = "Gamepassidhere"
local MarketplaceService= game:GetService("MarketplaceService")
if MarketplaceService:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, GamepassId) then
--code here
end
Okay thank you so much. I really needed that!