Hello, peeps. I am quite new to Roblox Lua and would like to know how to make a fading in and out gui when you're clicking a brick.
Ok. So first, insert a part into Workspace. Then insert in that part a script (not a localscript) and a clickdetector. Insert this code in the script:
script.Parent.ClickDetector.MouseClick:Connect(function(Character) game.ReplicatedStorage.FadeGui:FireClient(game.Players:WaitForChild("Character.Name")) -- Making a signal end)
You also have to insert a RemoteEvent in ReplicatedStorage named "FadeGui". Then, after editing your Gui in StartedGui, insert a localscript in the Gui and insert this code in the localscript:
local debounce = false local faded = false game.ReplicatedStorage.FadeGui.OnClientEvent:Connect(function() if debounce == false then debounce = true if faded == false then faded = true for i = 0, 1, 0.05 do script.Parent:WaitForChild(THE GUI OBJECT YOU WANNA FADE).BackgroundTransparency = i wait(.05) end return -- returning to the begenning of the function to not run the following lines, after setting "faded" to true else faded = false for i = 1, 0, -0.05 do script.Parent:WaitForChild(THE GUI OBJECT YOU WANNA FADE).BackgroundTransparency = i wait(.05) end debounce = false end end)
I made a signal for this (from a script to a localscript) cuz the scripts control SERVER events, and the localscripts just control a PLAYER'S event. So we don't want a script to change Gui objects, cuz else it will change the Gui of every players. We want to control the Gui object of a single player. To do this, I made a signal from a script to a localscript.
Hope this helped!