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)
01 | if hit.Parent:FindFirstChild( "Humanoid" ) ~ = nil then |
03 | if game.Players:FindFirstChild(hit.Parent.Name) ~ = nil then |
04 | local player = game.Players:FindFirstChild(hit.Parent.Name) |
06 | if player:FindFirstChild( "PlayerGui" ):FindFirstChild( "ScreenGui" ) = = nil then |
07 | sg = Instance.new( "ScreenGui" ) |
08 | sg.Parent = player:FindFirstChild( "PlayerGui" ) |
11 | if player.PlayerGui.ScreenGui:FindFirstChild( "MessageBox" ) = = nil then |
13 | local f = Instance.new( "Frame" ) |
15 | f.Position = UDim 2. new( 0.3 , 0 , 0.8 , 0 ) |
16 | f.Size = UDim 2. new( 0.4 , 0 , 0 , 50 ) |
17 | f.Style = "RobloxRound" |
18 | f.Parent = player.PlayerGui:FindFirstChild( "ScreenGui" ) |
20 | local m = Instance.new( "TextLabel" ) |
21 | m.Position = UDim 2. new( 0.5 , 0 , 0.5 , 0 ) |
23 | m.TextColor 3 = Color 3. new( 1 , 1 , 1 ) |
m.Text = "I'm not a part of the staff but, "
wait(2.5)
m.Text = "It's okay i guess..."
wait(3)
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