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

How can i make a screengui to destroy and not replay when i touch?

Asked by 5 years ago
Edited 5 years ago

` ``function onTouch(hit)

if hit.Parent:FindFirstChild("Humanoid") ~= nil then

    if game.Players:FindFirstChild(hit.Parent.Name) ~= nil then
    local player = game.Players:FindFirstChild(hit.Parent.Name)

        if player:FindFirstChild("PlayerGui"):FindFirstChild("ScreenGui") == nil then
        sg = Instance.new("ScreenGui")
        sg.Parent = player:FindFirstChild("PlayerGui")
        end

    if player.PlayerGui.ScreenGui:FindFirstChild("MessageBox") == nil then

    local f = Instance.new("Frame")
    f.Name = "MessageBox"
    f.Position = UDim2.new(0.3, 0, 0.8, 0)
    f.Size = UDim2.new(0.4, 0, 0, 50)           -- If Text box needs to be bigger, simply change "0.4"
    f.Style = "RobloxRound"                         -- Styles: "ChatBlue", "Chat Red", "Chat Green"
    f.Parent = player.PlayerGui:FindFirstChild("ScreenGui")

    local m = Instance.new("TextLabel")
    m.Position = UDim2.new(0.5, 0, 0.5, 0)
    m.FontSize = "Size14"                           -- Font Sizes: 10, 11, 12, 14, 18, 24
    m.TextColor3 = Color3.new(1,1,1)                -- Colors: (1,0,0) = Red, (0,1,0) = Green, (0,0,1) = Blue
    m.Parent = f

m.Text = "I'm not a part of the staff but, " wait(2.5)

m.Text = "It's okay i guess..." wait(3)


    f:Destroy()
    end
    end
end

end

script.Parent.Touched:connect(onTouch)```

I have this script and i want this to be destroyed after appearing but its replaying when i touch it again how can i make this

0
This is ironically bad right? User#24403 69 — 5y
0
I hope this is just a joke... SynthetickDev 188 — 5y
0
I think its called debounce or something? why do you think its a joke? TheMostDelikanliMan -14 — 5y
0
Lines 6 and 7 are the cause of the problem. After the script has fired and the ScreenGui has been destroyed, you're able to touch it again and it will create a new ScreenGui for you, as displayed on lines 6 and 7. It's best to remove those lines, or not, depending on if this post is most likely a joke or not. Seems like a joke to me. BiIinear 104 — 5y
View all comments (3 more)
0
add script.Disabled = true     this will disable the script. Put it on the first line WoTrox 345 — 5y
0
I'm confused. EmK530 143 — 5y

Answer this question