lionz is right
However, there are cases where you might want to do it the way you're doing it
The reason it's not working is because the "On Created" is triggering as soon as the Pistol is spawned, but before the pistol has been assigned an ID
the "On Created" trigger will activate as soon as an object is created, run the actions in this event, and then Construct will go back to where it left off
This isn't the case inside Functions. Inside functions, outside triggers will only be activated after the entire function has run. So you could put the pistol spawning and ID setting behavior inside a function, and it should work
The other way to deal with this is to put a "wait 0 seconds" as the first action in the second group of events. "Wait 0 seconds" waits until the next tick. So The pistol will be created, the "On Created" trigger will be activated, but then it will wait for 1 full tick before running the pin action, which will give the first group of events time to set the ID