I created a script (located in serverscriptstorage) and it is supposed to make an ImageButton and Frame visible if they own a certain gamepass. I don't know what's wrong with it; Can anyone help?
local gamepass = 382406860 while true do if game:GetService("GamePassService"):PlayerHasPass(player, gamepass) then script.Parent.Parent.StarterGui.ClassGui.Main.Vip.Visible = true script.Parent.Parent.StarterGui.ClassGui.Frame.Frame1.Visible = true end end
You would need a wait
in a loop.
local gamepass = 382406860 while wait() do if game:GetService("GamePassService"):PlayerHasPass(player, gamepass) then script.Parent.Parent.StarterGui.ClassGui.Main.Vip.Visible = true script.Parent.Parent.StarterGui.ClassGui.Frame.Frame1.Visible = true end end
Although a wait
is needed, The player
must be defined,and Lines 6-7 are wrong, StarterGui is the main container for Gui
elements, but PlayerGui
is the current interface container of the elements found in StarterGui
.
So, Without further ado.
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(ch) if game:GetService("GamePassService"):PlayerHasPass(player,382406860) then local playerGui = player:WaitForChild("PlayerGui").ClassGui playerGui.Main.Vip.Visible = true playerGui.Frame.Frame1.Visible = true end end) end)