So I’m trying to make a verse code that is only attaching props and devices to ONE player when they pick up a Vfx powerup. but when I tested it with multiple people it attached to all of them and was very glitchy and moving everywhere. but I just want ONE player at a time for it to be attached to every time the Vfx powerup is picked up. Also, for it to stop attaching to the player if they are eliminated
My code:
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/Temporary/SpatialMath }
A Verse-authored creative device that can be placed in a level
AttachPlayer := class (creative_device):
@editable MutatorZone : mutator_zone_device = mutator_zone_device{}
@editable VFXPowerup : visual_effect_powerup_device = visual_effect_powerup_device{}
@editable ExplosiveDevice : explosive_device = explosive_device{}
@editable WhiteDisk : creative_prop = creative_prop{}
@editable VFXSpawner : vfx_spawner_device = vfx_spawner_device{} # aAdd the radio device
@editable VFXCreator : vfx_creator_device = vfx_creator_device{}
OnBegin<override>()<suspends>:void=
VFXPowerup.ItemPickedUpEvent.Subscribe(AttachToPlayer)
AttachToPlayer(Agent : agent) : void=
spawn:
AttachToPlayerNew(Agent)
AttachToPlayerNew(Agent: agent)<suspends> : void=
if(FC := Agent.GetFortCharacter[]):
loop:
Sleep(0.1)
PlayerPos := FC.GetTransform().Translation
PlayerRot := FC.GetTransform().Rotation
spawn{WhiteDisk.MoveTo(PlayerPos + vector3{Z:= -70.0},PlayerRot, 0.1)}
spawn{MutatorZone.MoveTo(PlayerPos, PlayerRot, 0.1)}
spawn{ExplosiveDevice.MoveTo(PlayerPos + vector3{Z:= 120.0}, PlayerRot, 0.1)}
spawn{VFXSpawner.MoveTo(PlayerPos + vector3{Z:= 70.0},PlayerRot, 0.1)} # Move the radio device
spawn{VFXCreator.MoveTo(PlayerPos + vector3{Z:= 120.0}, PlayerRot, 0.1)}