Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Gamepass script not working correctly?

Asked by 5 years ago

Okay so, I have made a working teleport gui that I intend to make only usable for a gamepass called "Fast Travel". I have made this script here that seems to not be working.

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local id = 5068130
local hasPass = false

game.Players.PlayerAdded:connect(function(player)
    if hasPass == MarketplaceService:UserOwnsGamePassAsync(player.userId, id) then
player:findFirstChild("PlayerGui").FastTravel.Enabled = true 
player:findFirstChild("PlayerGui").FakeTravel.Enabled = false 
else player:findFirstChild("PlayerGui").FakeTravel.Enabled = true 
end
end)

There are 2 guis that this script is supposed to manipulate. "FastTravel" is the working teleport gui that I want to only be enabled for people with the gamepass. "FakeTravel" is the gui that has an identical open/close button to FastTravel, that I use as a placeholder for people without the pass so the spot does not look empty. For example, someone without the pass would have the placeholder button that does nothing, people with the pass will have the working gui entirely. For some reason the placeholder button is there 100% of the time, gamepass or not, and it is making it hard to continue on to my other gamepasses because of this. By default I have FastTravel disabled and FakeTravel Enabled. Both FastTravel and FakeTravel are ScreenGUI's. The Script is located in ServerScriptService.

0
Because the server can't access PlayerGui's descendants unless those descendants were placed by the server. And connect is deprecated use Connect. userId is also deprecated so use UserId User#19524 175 — 5y
0
So how would I fix it to where the playerguis can be accessed? OVOFinessinq 21 — 5y
0
You can't. You'll need remotes. User#19524 175 — 5y

Answer this question