Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Part touched, create gui, fade gui, destroy gui?

Asked by 5 years ago

first post and third time writing this, sorry 'bout crap formating...

I need help with this script, I want it to create a gui, then fade it, then delete it.

debounce = false

script.Parent.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and not debounce then
debounce = true
local gui = Instance.new('ScreenGui')
gui.Parent = player.PlayerGui
local frame = Instance.new('Frame')
frame.Parent = gui
frame.Size = UDim2.new(0, 1920, 0, 1080)
frame.BorderSizePixel = 0
frame.BackgroundColor3 = 0,0,0
frame.BackgroundTransparency = 0

for i = 0, 1.05, 0.05 do
    frame.BackgroundTransparency = i
    wait(0.01)
end

gui:Destroy()
frame:Destroy()
debounce = false
end
end)

sorry, it's a terrible script. Anyway, the spaced out bit is the part that I believe is the problem. I've looked up tons of scripts to fade ScreenGuis but this just doesn't work... any help? :\

0
So it doesn't work? NIMI5Q -2 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

the script looks good; just the for loop might be the problem. also, we'd appreciate to know what you see when you run your game;

I'd recommend writing the loop like this in this case

local tran=0
repeat  
    tran = tran+0.5
    frame.BackgroundTransparency = tran
    wait(0.01)
until frame.BackgroundTransparency <= 1
0
Yes! That worked thank you! scrawli 6 — 5y
0
np User#23252 26 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Your script is fine. Change frame.BackgroundColor3 = 0,0,0 to frame.BackgroundColor3 = Color3.new(0, 0, 0).

0
Thanks, that also helped. scrawli 6 — 5y

Answer this question