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

Shop Gui Won't Re Open Once Closed?

Asked by 4 years ago

Whenever You Step On The Part It Opens/Tweens The Gui Perfectly, But Once You Close It And Try To Open It Again, It Doesn't Open?

It Might Because I Opened It From A Client And Closed It Locally, But I'm Not Sure How To Fix This?

Part Serverscript

CanOpen = true

function onTouched(hit)
    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    if plr then
        if CanOpen == true then
            local shop = plr:WaitForChild("PlayerGui")
            local Main = shop.Main.PopUps.MainShopBag:TweenPosition(UDim2.new(0.298, 0,0.537, 0),nil, nil, 1)
            CanOpen = false
            wait(1)
            CanOpen = true
        end
    end
end

script.Parent.Touched:connect(onTouched)

GUI Close Script

script.Parent.Activated:Connect(function()
    script.Parent.Parent:TweenPosition(UDim2.new(0.298, 0,-0.537, 0), nil, nil, 1)
end)
0
For the touched script it would work better if it were a "normal" function instead of calling the function later on. PrismaticFruits 842 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

I think you're right, in that it does have to do with the server/local scripts. The reason it can open/close is because it must be set to closed at first, then the server opens it, and local scripts can read server-side changes so the local script knows it's open, and can close it. But, it can't open a second time, because the server script can't detect that the local script closed it.

An easy way to fix this, is to just put the .Touched event into the local script as well. Local scripts can still detect touches.

0
I personally use this, and so far it hasn't caused any issues for me. kkkeelan999 92 — 4y
Ad

Answer this question