#Start a thread and I'll explain if you
1 messages · Page 1 of 1 (latest)
For sure, just what you have will work and some people dont care to learn actually lol
I just want you to understand that you're getting a direct reference to your SCRIPT. Not, money.
yeah i got that part
That's why your naming doesn't make sense currently.
So you understand that it should be like targetController as your reference name.
And then from there, you can access everything you want in it.
such as money
waittt i think i just got what you mean
so like hold on
so your saying even if i put targetController here instead of Money i'd still be able to use the money variable and it would be less confusing?
or am i at a loss again
haha yeah, that's why i'm saying you don't quite understand yet. Yes, you would do targetController typically. Because you are referencing the ENTIRE script, NOT just money.
It's just a different variable name, it will all work, doesnt matter the name, but for clarity and so you understand, you should name it as the script and then access .Money from it.
ok ok so i change it from
public TargetController Money;
to
public TargetController targetController.Money;
Yup. Now, be sure you understand you have access to the whole script (so long as it's public). So you could have targetController.BankAccount, etc.
Or even a function:
targetController.MoveTarget()
you should get intellisense with all the options when you just do targetController.
when i do this now its saying it expects a () at the end
mannn
Your reference is:
public TargetController targetController
Now drag that object/script into that spot in the inspector.
Then in your code, you call targetController.Money
ok ok so i would then, confusingly change Money.Money -= 1 to targetController.Money.targetController.Money -= 1
I think you're still not making the connection that you have access to the entire script and your reference IS THE SCRIPT. Not, just money.
Can you explain how this makes sense?
targetController.Money.targetController.Money
like your asking to make sure i get it?
Your reference is targetController.
Now you want to access Money from that script.
yeah so i do targetController.Money i get that part
that's it. yes.
ok lmao
not twice.
like you have here
arent i doing it twice though cuz it means targetController.Money = targetController.Money - 1
dalphat told me to switch it to a dot in the middle instead of an = because it was giving me an error
Sure, same thing as:
targetController.Money -= 1
idk what this means
So now if you need something else from the target in this script you're in, you should understand how to access it hopefully.
ok yeah i just did access something else cuz i needed to make it change the text aswell
butttt before i go theres a new issue lmao rq
idk what the issue is but when i remove the second targetController.Money i get the error saying the name Money does not exist cuz it thinks im trying to do targetController = Money - 1 now
i think i need two of them man
Share your code.
the full thing rq?
sure
its pretty short but ill grab one of those websites for it
whats the command to pull up the list of them
A website to host temporary code snippets.
thats the full thing thats giving me the error i mentioned
can you share your TargetController script too?
Where is this variable defined?
😭
meant to switch that to targetController.Money
that would be the issue then
mb i copied the set text part from the targetcontroller and didnt realize
all good
alrrrr final test real quick
oops forgot to reference the object again lmao
okkk final test real quick again
alright it all works out 🙏
Nice! Congrats. As a small FYI, the code is not the best, as it makes no sense that a target would know about money, but you're learning to reference different scripts and learning in general, so it's good.
Just something to think about in the future 🙂
alr alr now would you be fine with me asking another kind of related but unrelated question
sure
now cuz im using this to set up buying something so i want you to only be able to do it after you have a certain amount of money right
so is there a way to add like an "and" type thing to the "if" part that checks the amount of money first aswell?
That sounds perfect to me.
alr ill try to set that up on my own
ill come back to the main beginner channel if i have any more issues but for now i should be fine
ty for all the help
Yup all good. Take a moment to think about what you'll need before writing the code. Helps to take a step back first.
omg sorry just wanted to say