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

Custom Chat GUI: How to fix Clone Nil error?

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.

4 comments

0

its :WaitForChild() not .WaitForChild() in line 3

0

I didn't ask about that nor did it fix the problem. But thanks for letting me know about that, didn't notice.

0

It would crash ur script if the plrgui was ever not immediately found (which is the reason to write the line like that)

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

1 answer

✓ Accepted answer

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

1 comment

0

Sorry, misread, made an edit to correct misinterpretation

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