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 6 years ago
Edited 6 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):

plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
char = plr.Character or plr.CharacterAdded:Wait()
plrgui = plr.PlayerGui or plr.WaitForChild("PlayerGui")
chatbox6 = script.Parent.Parent.MsgChatFrame.chatbox6

script.Parent.msgbar.FocusLost:Connect(function(enter)
    if enter then
        script.Parent.Parent.MsgChatFrame.chatbox1.Text = script.Parent.Parent.MsgChatFrame.chatbox2.Text
        script.Parent.Parent.MsgChatFrame.chatbox2.Text = script.Parent.Parent.MsgChatFrame.chatbox3.Text
        script.Parent.Parent.MsgChatFrame.chatbox3.Text = script.Parent.Parent.MsgChatFrame.chatbox4.Text
        script.Parent.Parent.MsgChatFrame.chatbox4.Text = script.Parent.Parent.MsgChatFrame.chatbox5.Text
        script.Parent.Parent.MsgChatFrame.chatbox5.Text = script.Parent.Parent.MsgChatFrame.chatbox6.Text
        script.Parent.Parent.MsgChatFrame.chatbox6.Text = script.Parent.msgbar.Text
        script.Parent.msgbar.Text = "Tap the \"/\" button or click here to chat"
        chatbox6.Text = "  "..char.Name..": "..chatbox6.Text
        script.Parent.Parent.MsgChatFrame.chatbox1.Text:Clone().Parent = plrgui.CustomChat.ChatFrame.MsgChatFrame.chatbox1.Text
        script.Parent.Parent.MsgChatFrame.chatbox2.Text:Clone().Parent = plrgui.CustomChat.ChatFrame.MsgChatFrame.chatbox2.Text
        script.Parent.Parent.MsgChatFrame.chatbox3.Text:Clone().Parent = plrgui.CustomChat.ChatFrame.MsgChatFrame.chatbox3.Text
        script.Parent.Parent.MsgChatFrame.chatbox4.Text:Clone().Parent = plrgui.CustomChat.ChatFrame.MsgChatFrame.chatbox4.Text
        script.Parent.Parent.MsgChatFrame.chatbox5.Text:Clone().Parent = plrgui.CustomChat.ChatFrame.MsgChatFrame.chatbox5.Text
        script.Parent.Parent.MsgChatFrame.chatbox6.Text:Clone().Parent = plrgui.CustomChat.ChatFrame.MsgChatFrame.chatbox6.Text
    end
end)

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 — 6y
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 — 6y
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 — 6y
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 — 6y

1 answer

Log in to vote
0
Answered by
Nonaz_jr 439 Moderation Voter
6 years ago
Edited 6 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..


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

Answer this question