Here are some very important things to remember whilst scripting:
- You can only access LocalPlayer (game.Players.LocalPlayer) from a LocalScript.
- You cannot edit a players GUI from a server script, as you have done from the "onserverevent script" (this is wrong). You can only edit GUI from a LocalScript.
With your script, you have completely messed up here so I'm just gonna rewrite it and consequently, as a bonus, give you good ways to organise scripts!
SERVER SCRIPT:
local MarketPlaceService = game:GetService("MarketPlaceService")
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
local GamePasses = {
GamePassNameHere = 5509969
}
local GamePassNameHere = {}
game.Players.PlayerAdded:Connect(function(player)
local UserId = player.UserId
GamePassNameHere[UserId] = MarketPlaceService:UserOwnsGamePassAsync(UserId,GamePasses.GamePassNameHere)
if GamePassNameHere[UserId] then
RemoteEvent:FireClient(player,"GamePassNameHere")
end
end
CLIENT SCRIPT (LOCAL SCRIPT):
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
RemoteEvent.OnClientEvent:Connect(function(tag)
print("Remote Event Received: "..tag)
if tag == "GamePassNameHere" then
playerGui.Trail2onoff.Enabled = false
playerGUI.moreguihere.Frame.Visible = true
elseif tag == "you can write more event's here if you want" then
end
end)
And that's it! Leave me an upvote or whatever if it was a good answer :) and if you see an error and/or have any questions i'll be glad to edit/answer.
1 comment
Put a print("it worked") below the onserverevent line and see if it prints, also put one after the fireserver line. That will tell us if the event is firing, and if the server is seeing it.