Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why can't my LocalScript find a GUI?

Asked by
Kratos232 105
10 years ago

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

Log in to vote
0
Answered by 10 years ago

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
Ad

Answer this question