Roblox is saying that an element doesn't exists even though it does

I’m trying to make a tween effect for a gui. And when I wrote the code and tested it out, I got an error in the output saying that a screengui named, Gui, was not a valid member of PlayerGui. So I checked the script and the startergui for any misspelling, and there was no misspelling for anything. And here’s the screengui right here and the error:

vbb
ccc

And here’s the code I used:

game.Players.PlayerAdded:Connect(function(player)
	local Frame = player.PlayerGui.Gui.Explode
	local ts = game:GetService("TweenService")
	local ti = TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
	local tOut = {BackgroundTransparency = 0}
	local createOut = ts:Create(Frame, ti, tOut)
	
	wait(5)
	createOut:Play()
end)
1 Like

Why are you manipulting GuiObjects through a serverscript? Also the solution is very simple.
Just do
local Frame = player.PlayerGui:WaitForChild(“Gui”).Explode

I’d recommend you doing it in client though

2 Likes

Don’t rely that everything will be replicated to the client when they join. Usually there is a small delay for everything to be set up. Use :WaitForChild() and it should fix the issue.

3 Likes

I’m doing a server script because it’s for an event that requires all players to see it.

Ok that’s why. I’ll remember to do that next time for these types of events. Thanks for your help!

Just do everything in client and use remote events.

Ok. I’ll try doing that next time. :slight_smile: