I have a script that makes your screen turn black every couple of seconds. I want to be able to press space and make the script make the screen turn black. Anyone know how I could do this?
Script is here just in case ya need it.
- while true do
- wait(20)
- for i,player in pairs(game.Players:GetChildren()) do
- local s=Instance.new("ScreenGui")
- s.Parent=player.PlayerGui
- local t=Instance.new("Frame")
- t.Size=UDim2.new(2,0,2,0)
- t.Position=UDim2.new(-0.5,0,-0.5,0)
- t.BackgroundColor3=Color3.new(0,0,0)
- t.ZIndex=-1
- t.Parent=s
- delay(0.2,function() s:remove() end)
- end
- end
Any help?

3 comments
Use a code block by clicking the Lua block and take off the "1."
remove() is deprecated, use Destroy()
also use the UserInputService for keyboard input