Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

2 comments

0

:connect is deprecated, maybe use :Connect. I think that might make a difference xD

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.

1 answer

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.

2 comments

0

When something is deprecated you should not use it.

0

I fixed the :Connect and the script still will not work. I am completely lost on how to fix it.

This discussion is preserved as it was. New answers, comments, and votes are closed.