I want to make the pet despawn when a button is pressed, but i do not know how to. I tried to figure it out, but i cant. Here is the code if anyone is willing to help:
spawn_pet_device2 := class(creative_device):
var Players : [ ]player = array{}
@editable
SpawnEgg : conditional_button_device = conditional_button_device{}
@editable
DebbyAsset : creative_prop_asset = DefaultCreativePropAsset
SpawnDebby( Agent : agent ) : void =
if (FortCharacter := Agent.GetFortCharacter[]):
PlayerPos := FortCharacter.GetTransform().Translation
PlayerForward := FortCharacter.GetViewRotation().GetLocalForward() * 300.0
DebbySpawnPos := PlayerPos + PlayerForward
Result := SpawnProp(DebbyAsset, DebbySpawnPos, rotation{})
if (SpawnedProp := Result(0)?):
spawn:
PetFollowsPlayer(FortCharacter, SpawnedProp)
PetFollowsPlayer( FortniteCharacter : fort_character, CreativeProp : creative_prop)<suspends> : void =
loop:
Sleep(0.0)
PlayerPos := FortniteCharacter.GetTransform().Translation
DebbyPos := CreativeProp.GetTransform().Translation
DistanceFromPlayer := Distance(PlayerPos, DebbyPos)
Time := DistanceFromPlayer / 350.0
CreativeProp.MoveTo(PlayerPos, rotation{}, Time)
OnBegin<override>()<suspends>:void=
set Players = GetPlayspace().GetPlayers()
SpawnEgg.ActivatedEvent.Subscribe(SpawnDebby)