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

Why can't my LocalScript find a GUI?

Hi. I'm making a GUI, and inside the GUI, there's a LocalScript. The LocalScript has to be local because it deals with things like KeyDown, and uses the Mouse. Anyway, at the start of the script, there's a bunch of Variables.

local Game = game -- Important Variable
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()

--[[ DeletedComment ]]--
local Chatting = false
local StartText = "Type '/' or Click here to Chat (Disabled for Guests)"


--[[ DeletedComment ]]--
local GUI = script.Parent
local ChatBar = script.Parent.ChatBar
local Chats = 0

When I test it in Studios, it works fine, even if the Variables aren't Local. But when I go on the Game Online, not on studios, it says that ChatBar isn't there, when it is.

How do I get it to work? (I know the local Game = game variable is useless...)

  • Kratos232

1 answer

✓ Accepted answer

I only see one problem with the script that could cause your issue...

In the section of code:

local ChatBar = script.Parent.ChatBar

you are trying to find a object named ChatBar that may not have loaded yet...

To fix this you should change it to:

local ChatBar = script.Parent:WaitForChild('ChatBar')

I hope this helped,

  • Darkness246810

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