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

Shop Gui Won't Re Open Once Closed?

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)

1 comment

0

For the touched script it would work better if it were a "normal" function instead of calling the function later on.

1 answer

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.

1 comment

0

I personally use this, and so far it hasn't caused any issues for me.

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