I use the Touched event of a brick to know when it is touched. Then I check to make sure the part that touched it is part of a character. And if they don't have the GUI I give it to them and start the countdown.
function NewGui()
local Gui = Instance.new("ScreenGui")
Gui.Name = "Countdown Gui"
local Tect = Instance.new("TextLabel",Gui)
Text.Name = "Countdown"
Text.Size = UDim2.new(0.3,0,0.3,0)
Text.Position = UDim2.new(0,0,0,0)
return Gui
end
script.Parent.Touched:connect(function(Part)
local Player = Game:GetService("Players"):GetPlayerFromCharacter(Part.Parent)
if Player and not Player.PlayerGui:FindFirstChild("Countdown Gui") then
local Gui = NewGui()
Gui.Parent = Player.PlayerGui
for i=30,0,-1 do
Gui.Countdown.Text = i
wait(1)
end
Player.Character:BreakJoints()
end
end)
1 comment
Do you put the script into the brick that will be touched? Also do i have to make the Gui or does the script make it for me?