I am trying to create a popup menu and it shows that the binding pressed is working but won't hide or show the UI. This is my code so far.
local propMenuUI = script:GetCustomProperty("MenuUI"):WaitForObject()
function OnBindingPressed(whichPlayer, binding)
print("player " .. whichPlayer.name .. " pressed binding: " .. binding)
if (binding == "ability_extra_20") then
if propMenuUI.visibility == Visibility.FORCE_ON then
propMenuUI.visibility = Visibility.FORCE_OFF
elseif propMenuUI.visibility == Visibility.FORCE_OFF then
propMenuUI.visibility = Visibility.FORCE_ON
end
end
end
function OnPlayerJoined(player)
-- hook up binding in player joined event here, move to more appropriate place if needed
player.bindingPressedEvent:Connect(OnBindingPressed)
end
-- on player joined/left functions need to be defined before calling event:Connect()
Game.playerJoinedEvent:Connect(OnPlayerJoined)