Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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? :\

1 comment

0

So it doesn't work?

2 answers

✓ Accepted answer

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

2 comments

0

Yes! That worked thank you!

0

np

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

1 comment

0

Thanks, that also helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.