Game pass team GUI isn't work

It should work now 433542543554%

This looks good and should be the answer to what @OP requires, although a few pieces of advice I would like to mention

I recommend you reference services via game:GetService(service) instead of game.Service as it ensures the service is given and not something else in the event that the name of the Service in the explorer is different, unlikely, but it 's always better to use a safer method. So in your cases where you use game.ReplicatedStorage for example, it’s better to use game:GetService("ReplicatedStorage") to ensure you get the service and as an added piece of advice, would be better off in a variable, but if it’s only used once, you can just directly get something from it, so

game.ReplicatedStorage.Tutorial:FireServer()

Would just be

game:GetService("ReplicatedStorage").Tutorial:FireServer()

Since you only reference ReplicatedStorage once, but still nice to put it in a variable and to reference the variable

Also you don’t need to set both the Team and TeamColor, one or the other is enough as setting the Team will automatically change the TeamColor to the TeamColor of the team, and setting the TeamColor will automatically set the Team for you.

That’s all I really have to say about it, besides that it should work for what @OP needs, and I like how you do the check from the server so exploiters who don’t have the gamepass can’t just fire it themselves, good notice!

@ImAGUIDesigner If you haven’t already, please try out what @ProBaturay has given you when placed accordingly, it should do exactly what you need and comes with proper sanity checking

1 Like

All good, all good! You’re a programmer, I must be sad, because I ask for that all… And yall answer and answer and take time for me!! I must be sad for that!

this should work promise. @ImAGUIDesigner

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)
1 Like

Don’t be, you need help it’s normal to help you. If you need help just ask. :slight_smile:

1 Like

But he don’t knows “player”

(20 Characters)

It’s a remoteevent it should know the player…

Thank you so much! :slight_smile:

No problem. :slight_smile:
If you have any questions contact me. MasterLoyalty#6780.

1 Like

Some of my critiques apply to this as well, the only thing different I want to include is to not do the if statement on the client, exploiters can easily fire the event themselves, bypassing the check altogether

@ImAGUIDesigner When firing to a Server RemoteEvent, the game automatically gives the player who fired the event as the first argument, you just need to specify the other arguments yourself, and the first parameter in OnServerEvent is reserved for the player who fired the event, so be careful for that

This does not apply to Clientsided RemoteEvents, you have to get the player yourself depending on what firing method you use, and OnClientEvent does not require the first parameter to be the player who fired it, since you can get the LocalPlayer

He don’t knows player :thinking:

1 Like

So you recommend to use if statement in the serverscript at OnServerEvent?

use

local player = game.Players.LocalPlayer
1 Like

Yes, @ProBaturay does it correctly it should be the answer because it does the checks accordingly

Also @ImAGUIDesigner after the local id line, do

local player = game:GetService("Players").LocalPlayer

Although again this is unneeded because the if statement should just be on the server

1 Like

why getservice and not game.Players.LocalPlayer? :thinking:

So it ensures you get the service you want, indexing it directly can be problamatic in the event you don’t get the service you wanted, either because you accidentally renamed the service or because of other issues,

Using GetService ensures you get the service because it gets it by ClassName lookup, whereas the typical method jsut indexes what it finds with the name Players. So if you rename a Service to Players and change the name of the Players service to something else, it’ll get the service you renamed instaed of the Players service, always good practice to use the method that ensures you get the right service

Thank you, you are a great teacher. :wink:

1 Like

It still doesn’t work :frowning:
Ya’ll don’t must do that, I hire a scripter :confused:

Thank ya’ll for your time :frowning:

Show output don’t I am gonna help you somehow

1 Like

Use @ProBaturay’s method it is exploit proof.

2 Likes