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

How do I make a gui disappear, that was activated by dialog, to disappear when a player walks away?

Asked by 5 years ago

I'm able to make the gui appear when a player responds to the NPC, but I can't seem to figure out how to make the gui disappear automatically when a player walks away from the conversation.

Dialog = script.Parent
Dialog.DialogChoiceSelected:connect(function(player,dialog)
    local ShopScreen = script.Parent.ShopScreen
    if dialog.Name == "OpenShop" then
        ShopScreen:Clone().Parent = player.PlayerGui
        local ShopScreenClone = player.PlayerGui.ShopScreen
        Background = ShopScreenClone.Background
        Features = ShopScreenClone.Features
        for i, child in pairs(ShopScreenClone:GetChildren()) do
            child.Visible = true
        end
        Background:TweenSizeAndPosition(UDim2.new(0, 400, 0, 400), UDim2.new(0.292, 0,0.081, 0), "In", "Quad", 2)
        wait(0.5)
        Features:TweenPosition(UDim2.new(0.294, 0,0.104, 0), "Out", "Quad", 0.5)
    end
end)
if Dialog.InUse == false then
    Background:TweenSizeAndPosition(UDim2.new(0, 0, 0, 0), UDim2.new(0.292, 0,0.081, 0), "In", "Quad", 2)
    Features:TweenPosition(UDim2.new(-1, 0,0.104, 0), "Out", "Quad", 0.5)
end
0
Not a request site! User#19524 175 — 5y
0
Could check magnitude of player to npc, and if they are out of a max range, then close the dialog. climethestair 1663 — 5y
0
If I were you, I wouldn't use DialogChoiceSelected. It doesn't work in FE games at all. bluestreakejjp 41 — 5y

Answer this question