UI.Parent is not working?

I got a weird error from editing

I already fixed the above error

But I have a new error

  1. What do you want to achieve? I want to create a !announce command with a custom UI I created

  2. What is the issue? After using the command, I got a warning from the waitforchild, which is waiting for the UI to be added in

  1. What solutions have you tried so far?
    I didn’t find any solutions.
local function OnEventFired(filteredannouncemsg, name)
	print(filteredannouncemsg)
	print(name)
	local ui = ReplicatedStorage.ScreenUis.Announcement:Clone()
	ui.Parent = game.Players.LocalPlayer.PlayerGui
	game.Players.LocalPlayer:WaitForChild("Announcement")
	wait(.5)
	
	ui.Frame.Announcement.Desc.Text = filteredannouncemsg
	ui.Frame.Announcement.Name.Text = name
end

image

All help is appreciated :grinning:

Sorry, I forgot to say that I fixed the above error with a WaitForChild function, which caused a new error.

Hey mate! Maybe try this instead.

local function OnEventFired(announcementmessage, name)
    for i, v in pairs(game:GetService("Players") do
       local UI = game.ReplicatedStorage.ScreenUis.Announcement:Clone(v.PlayerGui)
       ui.Frame.Announcement.Desc.Text = announcementmessage
	   ui.Frame.Announcement.Name.Text = name
   end
end
local function OnEventFired(filteredannouncemsg, name)
	print(filteredannouncemsg)
	print(name)
	local ui = game:GetService("ReplicatedStorage").ScreenUis.Announcement:Clone()
    local guis = game:GetService("Players").LocalPlayer.PlayerGui
	ui.Parent = guis
	guis:WaitForChild("Announcement")
	wait(.5)
	
	guis:WaitForChild("Announcement").Desc.Text = filteredannouncemsg
	guis:WaitForChild("Announcement").Name.Text = name
end

This should work, you wrote game.Players.LocalPlayer:WaitForChild(“Announcement”) while Announcement is inside the PlayerGui and not the localplayer itself!

I had the same thing today.

I also forgot to say that this is a local script…

Edit: I am going to try your example in a server script

i fixed alot of errors in your code, but the clone doesn’t seem to be working.

No errors, just the waitforchild warnings.


game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)

		if player:GetRankInGroup(11704424) >= 248 then
			local args = message:split(" ") -- Splits arguments.
			if args[1]:lower() == "!announce" then -- Checks if the command was used.
				local announcemsg = message:sub(args[1]:len() + 2,-1) -- Announce message in a variable.
				local filteredannouncemsg = ChatService:FilterStringForBroadcast(announcemsg, player) -- Filters the message with the chat filter system. (Required by Roblox!)
				wait(1) -- Waits 1 second so that the announce message is not sent to everyone before your command message.
				for i, v in pairs(game:GetService("Players"):GetPlayers()) do
					local UI = game.ReplicatedStorage.ScreenUis.Announcement:Clone(v.PlayerGui)
					v.PlayerGui:WaitForChild("Announcement")
					wait(.5)
					UI:WaitForChild("Frame").Announcement.Desc.Text = filteredannouncemsg
					UI:WaitForChild("Frame").Announcement.Name.Text = player.Name
				end
			end
		end

	end)
end)

ui.Frame.Announcement.Name.Text = name

The main error was from roblox not finding the text value in a name value, so I made a waitforchild function so roblox knows that i am looking for a child. But the solution post helped me out the most! Thanks