I am trying to make this message script only pop up one time. It works when the player touches the block and a message pops up. When the message is over and the player touches the block again it shows pops up again which is not what I want. Any help?
function message(m)
---------------------------------------------------------------\\
m.Text = "How do I make you pop up once?"
wait(5)
---------------------------------------------------------------//
-- Color codes:
-- (1,0,0) is Red
-- (0,1,0) is Green
-- (0,0,1) is Blue
-- (1,1,1) is White
-- And you can also mix colors. (1,0,1) is Purple for example
-- For more settings, read the green text around the section below
end
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
-- In this section below, you can edit how the text box looks like
local f = Instance.new("Frame")
f.Name = "MessageBox"
f.Position = UDim2.new(0.3, 0, 0.1, 0)
f.Size = UDim2.new(0.4, 0, 0, 0) -- 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, 500)
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
message(m)
f:Destroy()
end
end
end
end
script.Parent.Touched:connect(onTouch)

1 comment
I mean, you could remove the part you're using to trigger this once the message is finished and you're done displaying it. Though that may not be the best way.