When you declare attackers, you choose each attacking creature's target: either an opponent (or that opponent's commander in Commander) or a planeswalker that opponent controls (CR 508.1). These are two distinct legal targets for attacks.
An effect that says 'creatures can't attack you' (or 'you can't be attacked') restricts attacks aimed at that player specifically. It does not extend protection to permanents the player controls, including their planeswalkers, unless the effect explicitly says so (CR 508.1a, 915.0 — the restriction is on the player as an attack target).
Planeswalkers are attacked directly as independent targets during the declare attackers step. A creature attacks a planeswalker, not the player through the planeswalker, so the restriction on attacking the player simply does not apply (CR 508.1, 306.7).
Example: Your opponent has Ghostly Prison in play (creatures can't attack that player unless you pay mana) and also controls Liliana of the Veil. You may attack Liliana freely without paying the Ghostly Prison tax, because you are attacking the planeswalker, not the player.
If the effect instead said 'creatures can't attack you or planeswalkers you control,' then attacking either target would be prohibited. Always check whether the protective effect explicitly names planeswalkers.
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.