I am making a goal system. I got it down to the script below. The problem is that the UI stays up for a very long time and then goes a way. I want it to only wait 3 seconds and the disappear. How do I fix this
local part= script.Parent
local function showUI(frame)
for _, Player in pairs(game.Players:GetChildren()) do
Player.PlayerGui.GoalAlert.MainFrame.Visible = true
Player.PlayerGui.GoalAlert.MainFrame[frame].Visible = true
wait(3)
Player.PlayerGui.GoalAlert.MainFrame.Visible = false
Player.PlayerGui.GoalAlert.MainFrame[frame].Visible = false
end
end
local function oHitBox()
showUI("Blue")
end
local function bHitBox()
showUI("Red")
end
part.Touched:Connect(function(hit)
if hit.Name == "OHitBox" then
oHitBox()
elseif hit.Name == "BHitBox" then
bHitBox()
end
end)