Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Global Variable Problem ?

Asked by 5 years ago

Hey. I'm trying to make script for highlight the selected enemy but there is a really big problem i couldn't solve. First let me explain my goal. I want to place a circle under selected enemy and place arrow top of selected enemy's head. It should change location when new enemy selected and follow enemy's location. I'm cloning circle and arrow models from ReplicatedStorage to CurrentCamera with local script placed under StarterPlayerScripts. I need a loop for syncing circle's and arrow's position with enemy's position but i should change enemy position too when new enemy selected. I put global variable '_G.SelectedEnemyPos' and while loop that constantly change circle's position to that global variables position. But i can't access this global variable from the script placed under enemy. I have to access it because i have to change circle's trancparency to 1 when enemy is dead. Someone can kill that enemy too. Maybe someone can give me a new perspective. I'm really stuck i can't even think about it. I don't have any other solution. I'm not new at programming but i'm new at gaming there is a client and server they can't use same global variable. If you have a easier solution or new idea please share it to me. THANKS!

0
Oh my god, why can't you put a tl;dr or explain the problem directly instead of talking about circles? You could literally reword it to something like: "i set _G.SelectedEnemyPos" in this script <source>, but when I try to access it from this script it doesnt work: <source>" Amiaa16 3227 — 5y
0
I explained the whole situation because my method will be really bad. I'm open for all solutions or new way to solve it. Sorry for bother you. GeldiBaskan 13 — 5y

Answer this question