1. Hey! Guest! The XXX GMC Jam will take place between August 24th, 12:00 UTC (Friday noon) and August 27th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GML Need help with variables. (Quick Response Needed for deadline)

Discussion in 'Programming' started by Aram Potter, Aug 10, 2018.

  1. Aram Potter

    Aram Potter Member

    Joined:
    Aug 10, 2018
    Posts:
    2
    Hi all,

    I'm fairly new to Gamemaker and I need help with a small problem I'm having to do with some variables.

    I have 2 different integer variables: global.money and amount.

    What I am trying to do is take away the amount variable integer from the global.money integer when I click a button.

    What I've tried to do is, on left click: global.money -= amount;

    Please let me know what I am doing wrong, any help would be really appreciated.

    Thank you.
     
  2. atrus159

    atrus159 Member

    Joined:
    Aug 8, 2018
    Posts:
    26
    This seems to be correct, what's the bug you're having?
     
  3. BabyDukaCPH

    BabyDukaCPH Member

    Joined:
    Feb 8, 2017
    Posts:
    10
    Yeah, this sounds right. It's basically like saying a - b = c. Try going to the Scripts tab > Search In Scripts... and type in global.money - then you will have an overview of all the instances calling that variable. You can do the same with amount. And try putting more of the code from your event in a post
     
  4. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    4,966
    That code needs to be in the button object's mouse button left pressed event.
     
  5. flerpyderp

    flerpyderp Member

    Joined:
    Apr 26, 2018
    Posts:
    149
    Yes, since you haven't described the problem, we can only guess and offer solutions which might be irrelevant. If the problem is that global.money isn't changing despite the left mouse being clicked, check to see that you're not constantly setting it to a value in the step event somewhere.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice