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

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

Asked by
omorizz 50
2 years ago

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

Log in to vote
0
Answered by
bailley5 114
2 years ago
Edited 2 years ago

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)
Ad

Answer this question