Hello everyone, I want to make a script that makes a frame fade in when a proximity prompt is activated, and makes the same frame fade out when they press space.
It fades in just fine, but for some reason it doesn’t fade out; rather goes straight to transparent. Here is my code:
LocalScript in the frame:
local screen = script.Parent
local UIS = game:GetService("UserInputService")
local function FadeIn()
for i = 1, 0, -0.05 do
wait(0.02)
screen.Transparency = i
end
screen.Transparency = 0
end
local function FadeOut()
for i = 1, 0, 0.05 do
wait(0.2)
screen.Transparency = i
end
screen.Transparency = 1
end
game.ReplicatedStorage.MonitorEvent.OnClientEvent:Connect(function()
wait(2.75)
FadeIn()
end)
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.Space then
FadeOut()
end
end
end)
LocalScript that detects the button press:
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.Space then
camera.CameraType = Enum.CameraType.Custom
end
end
end)
end)
I appreciate any help.