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

This script I made is failing to work. I can't find any errors. Is there anything I messed up on?

Asked by 5 years ago
Edited 5 years ago

I made this script that is supposed to make a gui visible to a player whom owns the gamepass.

local id = 3484579

game.Players.PlayerAdded:connect(function(plr)
 plr.CharacterAdded:connect(function(char)
   if game:GetService('GamePassService'):PlayerHasPass(plr,id)then
  plr.PlayerGui.GamepassShop.Frame.Visible = true
 end
end)?

Line 3 makes sure the gui pops up when the player joins the game and Line 4 makes sure the gui stays visible after the player resets. Also the gamepass ID is valid and the game is published, so that shouldn't be causing the issue. Also the script is in ServerScriptService.

0
:connect is deprecated, maybe use :Connect. I think that might make a difference xD mixgingengerina10 223 — 5y
0
You can't edit anything in the PlayerGui from a server script, you can fire a remote event to the client that handles that. jackfrost178 242 — 5y

1 answer

Log in to vote
0
Answered by
Kyokamii 133
5 years ago
Edited 5 years ago

You seem to be missing an end statement for your CharacterAdded function. I'm surprised you didn't get any errors for that.

Here's what your code should look like:

local id = 3484579

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        if game:GetService('GamePassService'):PlayerHasPass(plr,id) then
            plr.PlayerGui.GamepassShop.Frame.Visible = true
        end
    end)
end)

As others have said, :connect is deprecated, but I don't think using it will break a script entirely. Still, it's good practice to use :Connect.

0
When something is deprecated you should not use it. valchip 789 — 5y
0
I fixed the :Connect and the script still will not work. I am completely lost on how to fix it. tawk1215 47 — 5y
Ad

Answer this question