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

Destroy() function Does Not work on Text Label?

So ive made a Diolauge System and When the Player clicks the option "Sure" I want A text Label to destroy. But thats the part im stuck on so could anyone help me. Here is the code


Local D = game.StartergGui.QuestGui.NoQ

Sure.MouseButton1Click:Connect(function() D:Destroy() <----------- That is the destroy code that doesent work

if script.Parent.Parent.Parent.TalkGui.TalkFrame.Dialogue.Text == "Hey kid Can you Do somthing for me?" then
	local text = "Well i cant find My radio, last time i saw it I was at this abbandoned place"
	local length = string.len(text)
	
	for i = 1, length do
							
		script.Parent.Parent.Parent.TalkGui.TalkFrame.Dialogue.Text = text:sub(1, i)
		wait(0.04)
	end
	
	
	wait(0.5)
	script.Parent.Parent.Parent.ButtonGui.ButtonFrame.Visible = false
	script.Parent.Visible = false
	
end

end)


Sure.MouseButton1Click:Connect(function()

game.StarterGui.QuestGui.NoQ:Destroy() <-------------- This is the code
if script.Parent.Parent.Parent.TalkGui.TalkFrame.Dialogue.Text == "Hey kid Can you Do somthing for me?" then
	local text = "Well i cant find My radio, last time i saw it I was at this abbandoned place"
	local length = string.len(text)
	
	for i = 1, length do
							
		script.Parent.Parent.Parent.TalkGui.TalkFrame.Dialogue.Text = text:sub(1, i)
		wait(0.04)
	end
	
	
	wait(0.5)
	script.Parent.Parent.Parent.ButtonGui.ButtonFrame.Visible = false
	script.Parent.Visible = false
	
end

end)


first I tried making a local Script then i tried doing it without the local script.

1 answer

✓ Accepted answer

game.StarterGui are the Guis, that get loaded into the "PlayerGui" each player has it's own PlayerGui, only accessible by the server or the local Client. So you have to get the LocalPlayer.

local D = game.Players.LocalPlayer.PlayerGui.QuestGui.NoQ

Sure.MouseButton1Click:Connect(function()
 D:Destroy() 
end)

5 comments

0

I wil Try that out and thanks

0

I got this In my output "QuestGui is not a valid member of PlayerGui "Players.IOwnRobloxP.PlayerGui". and The Gui didint destroy. What should I do?

0

That will usually mean that you do not have the GuestGui present in the PlayerGui. Make sure that it's present in the StarterGui so it can replicate to the PlayerGui.

1

I fixed it By doing this game.Players.LocalPlayer.PlayerGui.QuestGui.NoQ:Destroy() And Thank You very Much :)

0

No problem :) I would appreciate it when you accept my answer

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