Need help with function

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

  • 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.

TimeSkull

Member
Dec 13, 2022
1
0
1
36
I'm going bald over a function I'm trying to create, I've seen so many errors along the way but now there's NO ERROR with the code but it's still not working.

What I want to happen:
A player mines deepslate redstone ore and receives money for it unless the player is using a pickaxe with silk touch.

What happens:
Nothing happens. No errors while loading the script.

Code:
options:
    deepslate_redstone: random number between 0.75 and 1.25

function minemoney(p: player, b: block, ore: text, opt: text):
    if {_b} is {_ore}:
        if {_p}'s tool is enchanted with silk touch:
            send action bar "&5 No money due to using &fsilk touch" to {_p}
        else:
            set {_1} to {_opt}
            add {_1} to balance of {_p}
            send action bar "&d You got &f$%{_1}% &dfrom mining gold ore." to {_p}

on block break:
    minemoney(player, event-block, "deepslate_redstone_ore", "{@deepslate_redstone}")

This code works:
Code:
options:
    copper: random number between 0.2 and 0.5
on block break:
    if event-block is copper_ore:
        if player's tool is enchanted with silk touch:
            send action bar "&5 No money due to using &fsilk touch" to player
        else:
            set {_copper} to {@copper}
            add {_copper} to balance of player
            send action bar "&d You got &f$%{_copper}% &dfrom mining copper ore." to player
[doublepost=1670970849,1670963669][/doublepost]Solved via Discord: Was using wrong types.
 
Status
Not open for further replies.