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

How to close shop GUI once a players team changes?

Asked by 4 years ago

I was making a shop GUI and I only want to make it so that players spectating can use it. I tried making a script that closes the shop once the players team changes but it doesn't seem to work or give errors. This is what it looks like:

function Changed()
    if script.Parent.Parent.Parent.Team == game.Teams.Playing then
        repeat
        wait(1)
        script.Parent.ShopButton.Visible = false
        script.Parent.ShopHolder.Visible = false
        until
        script.Parent.Parent.Parent.Team == game.Teams.Spectating
        script.Parent.ShopButton.Visible = true
    end
end

script.Parent.Parent.Parent:GetPropertyChangedSignal("Team"):Connect(Changed)

I also tried to use:

script.Parent.Parent.Parent.Changed:Connect(Changed)

but that doesn't work either.

Answer this question