Hello @StormLight!
1. I'm glad you took inspiration from the skript i made, really makes me happy
2. I don't know whats wrong with this skript... here is the main stuff in my skript:
function spawnmob(loc: location, entity: entity type):
spawn {_entity} at {_loc}
command /pig:
permission: pig
permission message: Hey, you can't use this command!
trigger:
spawnmob(location of player, pig)
set name of last spawned entity to "World Border"
set {entity} to last spawned entity
every tick in world "world": # will be laggy, suggest 5 ticks for better performance
set {x} to x-position of {entity}
set {z} to z-position of {entity}
make console execute command "worldborder center %{x}% %{z}%"
hopefully this helps, again, i don't know what's wrong with your skript... maybe it's the different variables? although keep in mind with this skript i sent it dosent save the entity, so you have to do /pig again when the server restarts.