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 3 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

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

Log in to vote
0
Answered by
sayer80 457 Moderation Voter
3 years ago
Edited 3 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.

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

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

Answer this question