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

How do i make it so that when i click a part a fading in and out gui appears?

Asked by 2 years ago

I've been trying to make it so that when you click a part there's a black gui that fades in and fades out for a week and could'nt make it. I've tried using this script wich i put in the GUI

01local debounce = false
02local faded = false
03 
04game.ReplicatedStorage.FadeGui.OnClientEvent:Connect(function()
05    if debounce == false then
06        debounce = true
07        if faded == false then
08            faded = true
09            for i = 0, 1, 0.05 do
10                script.Parent:WaitForChild(THE GUI OBJECT YOU WANNA FADE).BackgroundTransparency = i
11                wait(.05)
12            end
13            return -- returning to the beginning of the function to not run the following lines, after setting "faded" to true
14          else
15            faded = false
View all 22 lines...

And then i put this script in the part

1script.Parent.ClickDetector.MouseClick:Connect(function(Character)
2game.ReplicatedStorage.FadeGui:FireClient(game.Players:WaitForChild("Character.Name")) -- Making a signal
3end)

But it didn't work. Then i tried using this script but when i change it it stops working:

01--< Variables >
02local part = game.Workspace.ClickMe
03 
04local frame = script.Parent.Frame
05 
06local db = false
07 
08local TimeBetweenFade = 3
09--< Set up >
10frame.BackgroundTransparency = 1
11frame.Visible = true
12--< Event >
13part.ClickDetector.MouseClick:Connect(function()
14    if not db then
15        db = true
View all 36 lines...

Example, if i change the TimeBetweenFade, it stops working. Could anyone please tell me how to do it. Oh and just to clarify, these aren't my scripts, I just found them.

0
you did not set db to false so it only works once Puppynniko 1059 — 2y
0
in what script? hellmet1 42 — 2y
0
both of them Puppynniko 1059 — 2y

1 answer

Log in to vote
0
Answered by
Puppynniko 1059 Moderation Voter
2 years ago

place in the frame and define your clickdetector

01local Frame = script.Parent
02local ClickDetector = workspace.Part.ClickDetector
03local TweenS = game:GetService("TweenService")
04local Db = false
05local FadeTime = .5
06ClickDetector.MouseClick:Connect(function()
07    if not Db then
08        Db = true
09        TweenS:Create(Frame,TweenInfo.new(FadeTime),{BackgroundTransparency = 0}):Play()
10        task.wait(FadeTime)
11        TweenS:Create(Frame,TweenInfo.new(FadeTime),{BackgroundTransparency = 1}):Play()
12        task.wait(FadeTime) --waits for the last tween to finish
13        Db = false
14    end
15end)
0
It still doesn't work. I've tried putting this localscript in the Frame and it didn't work, then in the Gui but it still didn't work. hellmet1 42 — 2y
0
did you set the click detector path? Puppynniko 1059 — 2y
0
By that do you mean like the name of the Part that has the clickdetector? Yeah i did hellmet1 42 — 2y
0
is the script the child of the frame you want to fade in and out Puppynniko 1059 — 2y
View all comments (11 more)
0
Yeah it is hellmet1 42 — 2y
0
it should work is there any errors? Puppynniko 1059 — 2y
0
No, Strangely there aren't any errors, maybe it has to do with the properties of the frame.. I don't really know hellmet1 42 — 2y
0
your frame's visible property is set to false if not try testing it on a new frame Puppynniko 1059 — 2y
0
Yeah it is, but how am i supposed to see if it is set to true? Maybe I'll just try setting the transparency to 1. If it still doesn't work I'll test it in a new game. hellmet1 42 — 2y
0
Set the transparency to 1 on a normal frame but if theres other things you'll have to use a For loop Puppynniko 1059 — 2y
0
Alright, i managed to make it work, the thing is that if i set it to ten it takes a lot of time to fade, how do i fix that? hellmet1 42 — 2y
0
Oh another thing, if there's many parts with the same name it won't work and for some reason it doesn't detect the clickdetector. hellmet1 42 — 2y
0
is it the wait thats too long if so you can change it in line 10 Task.Wait() also the reason i dont use Tween.Completed is cus its very late/it does not fire when it finished exactly and the reason it does not detect the clickdetector is sometimes roblox is bad at detecting if your mouse is on the part Puppynniko 1059 — 2y
0
Oh alright, i fixed it, thank you so much for helping dude! hellmet1 42 — 2y
0
np Puppynniko 1059 — 2y
Ad

Answer this question