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

how to make a gui fade in / out on part touch?

i know how to make a gui appear when a part is touched, but i want the gui to fade in and then fade out but i'm not sure how to add that? would it work with the script i have?

this is the script i currently have, but it doesnt fade

Popup = script.Parent.ScreenGui
Ready = true
function onTouch(hit)
 local h = hit.Parent:FindFirstChild("Humanoid")
 if h ~= nil and Ready == true then
  Ready = false
  local plyr = game.Players:FindFirstChild(h.Parent.Name) 
  local c = Popup:clone()
  c.Parent = plyr.PlayerGui
  wait(3)
  c:remove()
  wait(1)
  Ready = true
 end
end

1 answer

You can use tweens!

Popup = script.Parent.ScreenGui
Ready = true
local TS = game:GetService("TweenService")
script.Parent.Touched:Connect(function(hit)
	local h = hit.Parent:FindFirstChild("Humanoid")
	if h ~= nil and Ready == true then
		Ready = false
		local plyr = game.Players:FindFirstChild(h.Parent.Name) 
		local c = Popup:clone()
		c.Parent = plyr.PlayerGui
		wait(3)
		local Goal = {}
		Goal.Transparency = 1 -- Goal.ValueToChange = What to change to

		local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

		local tween = TS:Create(Popup.Frame, tweenInfo, Goal) --Make sure to put your frame/gui object here!
		tween:Play() -- Play the tween
		wait(1)
		Ready = true
	
end
end)

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