Solved Need help with a sign shop script.

  • 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 community!

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

redstone_pro180

New Member
May 7, 2022
7
0
1
I have a dupe server on 1.17.1 and i am trying to make it so players can buy items from a shop using coins earned by killing other players, everything works except the the script that gives you the bought item and subtracts the required coins.

Code:
on right click:
 block is a sign
 line 1 is "BUY"
 set {Cost} to line 2
 {Coins.%player%} is greater than {Cost} - 1
 set {Item} to line 3
 add {item} to player's inventory
 subtract {Cost} from {Coins.%player%}
 message "<green>bought %{item}%!"

How can i make this work?
 
You should use {Coins::%player%} instead of {Coins.%player%} as having a list works better rather than creating a new variable for each person. Keeping this in mind, this should work:
Code:
on right click:
 block is a sign
 line 1 is "BUY"
 set {Cost} to line 2
 if {Coins::%player%} >= ({Cost} - 1):
  set {Item} to line 3
  add {item} to player's inventory
  set {Coins::%player%} to ({Coins::%player%} - {Cost})
  send "<green>bought %{item}%!" to player
 else:
  send "&cError: not enough coins" to player
 
Status
Not open for further replies.