1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!


    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.


Discussion in 'Skript' started by TullyMastully, Aug 23, 2017.

Thread Status:
Not open for further replies.
  1. TullyMastully

    TullyMastully Member

    Aug 9, 2017
    Likes Received:
    I'm currently making a pet skript,
    and I wanted to know how to make it so if a player is on a horse for example, and click on shift or something else to not ride the horse, it will despawn the horse.

    Thanks in advance,
  2. ShaneBee

    Supporter + Addon Developer

    Sep 7, 2017
    Likes Received:
    So you're trying to make an item that, when clicked, makes you ride a horse or something like that, and you want that when you stop riding it, it disappears?

    Using the UUID from the nbt of the horse, setting that to a variable and checking, on a radius aroud the player, if any entity has said UUID when you dismount will work.

    The player teleports when he dismounts, so you can use that event to check if they dismounted the horse. If the UUID variable is set, then delete the entity that has said UUID.

    You should also cancel inventory clicks while mounted as they could remove the saddle

    Code (Skript):
    1. spawn adult horse 1 meter above the player
    2. make player ride last spawned adult horse
    3. set {_text} to "%nbt of last spawned adult horse%"
    4. set {_uuid::*} to {_text} split at "UUIDMost"
    5. set {_uuid2::*} to {_uuid::2} split at ","
    6. set {-ridinghorse.%player%} to {_uuid2::1}
    7. add "{Variant:%{_variant}%,CustomName:%{_nombre}%,CustomNameVisible:1,PersistenceRequired:0b,Attributes:[{Name:""generic.maxHealth"",Base:20},{Name:""generic.movementSpeed"",Base:%{_speed}%f},{Name:""horse.jumpStrength"",Base:%{_jump}%f}],Invulnerable:1,SaddleItem:{id:saddle,Count:1},ArmorItem:{id:""minecraft:%{_armadura}%"",Count:1b,Damage:0s},Tame:1,ActiveEffects:[{Id:11,Amplifier:6,Duration:2147483647,ShowParticles:0b}]}" to nbt of player's vehicle
    9. on teleport:
    10.     {-ridinghorse.%player%} is set
    11.     loop all entities in radius 20 around player:
    12.         set {_text} to "%nbt of loop-entity%"
    13.         set {_uuid::*} to {_text} split at "UUIDMost"
    14.         set {_uuid2::*} to {_uuid::2} split at ","
    15.         {_uuid2::1}=={-ridinghorse.%player%}
    16.         delete loop-entity
    17.         stop loop
    Taken from my custom skript for horses on my server, take what you need. The UUID of the horse is stored on {-ridinghorse.%player%}
Thread Status:
Not open for further replies.

Share This Page