I Have made a script that opens a gui for a player once the player clicks on the gui, I Did it in 2 games, in one of them it worked perfectly fine and opened the gui but in the other one it said that PlayerGui is not a valid member of Players.
I Used the same script in both of the games.
The script i used:
script.Parent.MouseClick:Connect(function(player)
local gui = player.PlayerGui["ShopGui"]
print(player.Name)
gui.Enabled = true
end)
Ok so I tried it in a baseplate and it printed my name and worked, and I found the error, there was another script in a gui called âOpeningâ where it runs a script once the player joins but what exactly disabled player gui in it?
script.Parent.Enabled = true
script.Parent.Background.BackgroundTransparency = 0
local randomtext = math.random(1,5)
script.Parent.Sound:Play()
wait(0.1)
script.Parent.TextLabel.Text = "a game made by..."
wait(5)
script.Parent.TextLabel.Text = "nomcell"
wait(1)
if randomtext == 1 then
script.Parent.TextLabel.Text = "original content"
end
if randomtext == 2 then
script.Parent.TextLabel.Text = "fnf text reference"
end
if randomtext == 3 then
script.Parent.TextLabel.Text = "dababy or dabibi?"
end
if randomtext == 4 then
script.Parent.TextLabel.Text = "ye i can get freky friday night"
end
if randomtext == 5 then
script.Parent.TextLabel.Text = "kidnapped by Arlel_Dreemurr"
end
wait(2)
script.Parent.TextLabel.Text = "Nomcell's hell"
script.Parent.TextButton.TextTransparency = 0
local tw = game:GetService("TweenService")
local dest = {}
dest.Position = UDim2.new(0.433, 0, 0.684, 0)
local tweeninfo1 = TweenInfo.new(1.5,Enum.EasingStyle.Back,Enum.EasingDirection.In,0,false,0)
local fin = tw:Create(script.Parent.TextButton,tweeninfo1,dest)
fin:Play()