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

Destroy() function Does Not work on Text Label?

Asked by 4 years ago

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

01if script.Parent.Parent.Parent.TalkGui.TalkFrame.Dialogue.Text == "Hey kid Can you Do somthing for me?" then
02    local text = "Well i cant find My radio, last time i saw it I was at this abbandoned place"
03    local length = string.len(text)
04 
05    for i = 1, length do
06 
07        script.Parent.Parent.Parent.TalkGui.TalkFrame.Dialogue.Text = text:sub(1, i)
08        wait(0.04)
09    end
10 
11 
12    wait(0.5)
13    script.Parent.Parent.Parent.ButtonGui.ButtonFrame.Visible = false
14    script.Parent.Visible = false
15 
16end

end)

Sure.MouseButton1Click:Connect(function()

01game.StarterGui.QuestGui.NoQ:Destroy() <-------------- This is the code
02if script.Parent.Parent.Parent.TalkGui.TalkFrame.Dialogue.Text == "Hey kid Can you Do somthing for me?" then
03    local text = "Well i cant find My radio, last time i saw it I was at this abbandoned place"
04    local length = string.len(text)
05 
06    for i = 1, length do
07 
08        script.Parent.Parent.Parent.TalkGui.TalkFrame.Dialogue.Text = text:sub(1, i)
09        wait(0.04)
10    end
11 
12 
13    wait(0.5)
14    script.Parent.Parent.Parent.ButtonGui.ButtonFrame.Visible = false
15    script.Parent.Visible = false
16 
17end

end)

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

1 answer

Log in to vote
0
Answered by
sayer80 457 Moderation Voter
4 years ago
Edited 4 years ago

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.

1local D = game.Players.LocalPlayer.PlayerGui.QuestGui.NoQ
2 
3Sure.MouseButton1Click:Connect(function()
4 D:Destroy()
5end)
0
I wil Try that out and thanks Iownrobloxp 44 — 4y
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? Iownrobloxp 44 — 4y
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. RazzyPlayz 497 — 4y
1
I fixed it By doing this game.Players.LocalPlayer.PlayerGui.QuestGui.NoQ:Destroy() And Thank You very Much :) Iownrobloxp 44 — 4y
0
No problem :) I would appreciate it when you accept my answer sayer80 457 — 4y
Ad

Answer this question