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

I think this code is suppose to enable a ScreenGui, but it's not working! Can someone help?

Asked by 6 years ago

I have a piece of code, and it SHOULD enable a screengui whenever a player has a gamepass, but it's not working! Can someone please help? Code:

01local MarketplaceService = game:GetService("MarketplaceService")
02local Players = game:GetService("Players")
03 
04local gamePassID = 4439769  -- Change this to your game pass ID
05 
06function onPlayerSpawned(player)
07 
08    local hasPass = false
09 
10    -- Check if the player already owns the game pass
11    local success, message = pcall(function()
12        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID)
13        print("Has Game Pass")
14    end)
15 
View all 34 lines...
0
Anyting on output(F9) Leamir 3138 — 6y
0
Yeah, Its saying Playerspawned is not a member of Player, and it's saying 'Serverscriptservice.Script' line 34 SBlankthorn 329 — 6y

1 answer

Log in to vote
3
Answered by 6 years ago
Edited 6 years ago

If you have FE enabled, then the script will not work because the server cannot change properties of the gui.

Also the event should be this

1Players.PlayerAdded:Connect(onPlayerSpawned)
0
OMG THIS MADE IT WORK. THANK YOU SO SO SO MUCH. SBlankthorn 329 — 6y
Ad

Answer this question