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

Custom Chat GUI: How to fix Clone Nil error?

Asked by 7 years ago
Edited 7 years ago

Hello. I'm getting an error of 12:20:25.932 - Players.SilverCreeper58.PlayerGui.CustomChat.ChatFrame.ChatBar.TriggerChatSend:16: attempt to call method 'Clone' (a nil value). I don't understand how you can fix this.

Here's the Script (regular):

01plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
02char = plr.Character or plr.CharacterAdded:Wait()
03plrgui = plr.PlayerGui or plr.WaitForChild("PlayerGui")
04chatbox6 = script.Parent.Parent.MsgChatFrame.chatbox6
05 
06script.Parent.msgbar.FocusLost:Connect(function(enter)
07    if enter then
08        script.Parent.Parent.MsgChatFrame.chatbox1.Text = script.Parent.Parent.MsgChatFrame.chatbox2.Text
09        script.Parent.Parent.MsgChatFrame.chatbox2.Text = script.Parent.Parent.MsgChatFrame.chatbox3.Text
10        script.Parent.Parent.MsgChatFrame.chatbox3.Text = script.Parent.Parent.MsgChatFrame.chatbox4.Text
11        script.Parent.Parent.MsgChatFrame.chatbox4.Text = script.Parent.Parent.MsgChatFrame.chatbox5.Text
12        script.Parent.Parent.MsgChatFrame.chatbox5.Text = script.Parent.Parent.MsgChatFrame.chatbox6.Text
13        script.Parent.Parent.MsgChatFrame.chatbox6.Text = script.Parent.msgbar.Text
14        script.Parent.msgbar.Text = "Tap the \"/\" button or click here to chat"
15        chatbox6.Text = "  "..char.Name..": "..chatbox6.Text
View all 23 lines...

This just checks if the player has pressed enter. Then when the message goes through, all the messages go up by one chatbox space. After that, it "should" clone them and put it in the PlayerGui.

Yes I know... it doesn't look the best, but whatever. This is the script. I know it has something to do with lines 16 - 21.

0
its :WaitForChild() not .WaitForChild() in line 3 Gey4Jesus69 2705 — 7y
0
I didn't ask about that nor did it fix the problem. But thanks for letting me know about that, didn't notice. SilverCreeper58 23 — 7y
0
It would crash ur script if the plrgui was ever not immediately found (which is the reason to write the line like that) Nonaz_jr 439 — 7y
0
to make it more readable, store reusable parts of the link to your objects in a variable.. like changing plrgui.CustomChat.ChatFrame.MsgChatFrame.chatbox1.Text to GUImsgChatFrame.chatbox1.Text after local GUImsgChatFrame = plrgui.CustomChat.ChatFrame.MsgChatFrame etc Nonaz_jr 439 — 7y

1 answer

Log in to vote
0
Answered by
Nonaz_jr 439 Moderation Voter
7 years ago
Edited 7 years ago

you are attempting to clone a string value held in the Text property of your textbox. Then you attempt to set it's parent to another text value. Remove ".Text"

also, use a for loop for this, please..

1for i = 1, 6 do
2 local myChatBox = script.Parent.Parent.MsgChatFrame:FindFirstChild("chatbox"..i")
3 local b = plrgui.CustomChat.ChatFrame.MsgChatFrame:FindFirstChild("chatbox"..i")
4 myChatBox:Clone().Parent = b
5end
0
Sorry, misread, made an edit to correct misinterpretation Nonaz_jr 439 — 7y
Ad

Answer this question