Hello! I wanted to make a game pass team, that you can choose in a GUI (button)
But something isn’t working
Can you help me, please? (I’m a noob at scripting)
LocalScript:
local id = 17167151
local player = script.Parent.Parent.Parent.Parent.Parent.Players.LocalPlayer
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id) then
player.BrickColor.new = ("White")
end
2 Likes
Your script is a bit incorrect. You are trying to pass the player to a certain team if the player owned the gamepass. But I’d rather run the script from the server.
local MarketplaceService = game:GetService("MarketplaceService")
local ID = 17167151
game:GetService("Players").PlayerAdded:Connect(function(player)
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, ID) then
player.Team = game:GetService("Teams").White
player.TeamColor = game:GetService("Teams").White.TeamColor
end
end)
1 Like
Oh, there was a lot missing…
But uhm… I want to make a GUI button, when you click on it, you will become the team, if you don’t have the game pass happens nothing.
Then you will have a button inside StarterGui. When it is pressed, the server will check if the player has the gamepass, so in the client script located in button
script.Parent.Activated:Connect(function()
game:GetService("ReplicatedStorage").Tutorial:FireServer()
end)
And the server script,
local MarketplaceService = game:GetService("MarketplaceService")
local ID = 17167151
game:GetService("ReplicatedStorage").Tutorial.OnServerEvent:Connect(function(player)
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, ID) then
player.Team = game:GetService("Teams").White
end
end)
Add a RemoteEvent to ReplicatedStorage so you can manage the functions in the server script with the client.
3 Likes
So the first script into the button and the second one into ServerScriptService?
(I’m really dumb, please forgive me)
Yes, the first script will be inside the button and the second one ServerScriptService.
1 Like
You can’t tell the player to make his self white, you can do this but make sure it’s a localscript and if you want to show it to everyone his team you’ll have to use a remoteevent:
local id = 17167151
local player = game.Players.LocalPlayer
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id) then
player.TeamColor = BrickColor.new("White")
end
OK
(30 Characters)
(30 Characters)
I try it
Make sure the the team color is white because you tell the player to make his team color white which will get the first team in the team service that is white.
I did. The team color is white.
You can also use this:
local id = 17167151
local player = game.Players.LocalPlayer
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id) then
player.Team = game.Teams["TeamNameHere"]
end
You will have assigned the player to the team by the client. But the server will be unable to see this.
Put a remoteevent in replicated storage then put a localscript in any button of them you can name the remote event however you want just change the “TeamEvent1” to the remoteevents name
and copy this:
local id = 17167151
script.Parent.MouseButton1Click:Connect(function()
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id) then
game:GetService("ReplicatedStorage").TeamEvent1:FireServer()
end
end)
-------------------------------------------------------------------------
game:GetService("ReplicatedStorage").TeamEvent1.OnServerEvent:Connect(function(player)
player.Team = game.Teams["TeamNameHere"]
end)
The under one in a script in serverscriptservice and the above one in a localscript in any button @ImAGUIDesigner
Show me the output please!
1 Like
I did a mistake sorry let me edit it
1 Like