Jump to content

I need help with a random sword generator


zyria

Recommended Posts

For some odd reason my skript will not work and i can't figure it out please help
 

on load:
	clear {_swords::*}
	add "iron sword", "diamond sword" and "stone sword" to {_swords::*}
command sword:
	trigger:
		set {_random} to a random element of {_swords::*}
		give {_random} to player
		send "test"

 

Edited by zyria
Link to comment
Share on other sites

When you're adding the items to the list you're adding strings, not items. Also, I belive that the swords variable is local and not global which means you can't access the sword variable from the sword command. I might be wrong on that though, I'm quite new to skript. 

I would belive this works:

on load:
	set {swords::*} to diamond sword, iron sword and stone sword

command /sword:
	trigger:
		set {_random} to a random element of {swords::*}
		give {_random} to player
		send "&cHere's a random sword!" to player
Link to comment
Share on other sites

3 hours ago, Znyx said:

When you're adding the items to the list you're adding strings, not items. Also, I belive that the swords variable is local and not global which means you can't access the sword variable from the sword command. I might be wrong on that though, I'm quite new to skript. 

I would belive this works:

on load:
	set {swords::*} to diamond sword, iron sword and stone sword

command /sword:
	trigger:
		set {_random} to a random element of {swords::*}
		give {_random} to player
		send "&cHere's a random sword!" to player

yes this fixes it

Discord: Dead#6905

Love anime!


Anime Gifs

Link to comment
Share on other sites

  • 4 months later...
On 3/2/2023 at 4:50 PM, zyria said:

For some odd reason my skript will not work and i can't figure it out please help
 

on load:
	clear {_swords::*}
	add "iron sword", "diamond sword" and "stone sword" to {_swords::*}
command sword:
	trigger:
		set {_random} to a random element of {_swords::*}
		give {_random} to player
		send "test"

 

on load:
    clear {_swords::*}
    add "iron sword", "diamond sword" and "stone sword" to {_swords::*}
command /sword:
    trigger:
        set {_random} to a random element of {_swords::*}
        give {_random} to player
        send "test"
Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...