If statement issue

Hello, thank you for reading this. I’m having an issue with “Values”, I made an if statement saying the following:
Help

If anyone could help me it would be greatly appreciated. I’ve been trying to fix it and it won’t bother working.

2 Likes

Also, I get no errors in output I’ve tried using <,>,== they don’t seem to work I’ve also tried making it a local script that didn’t work, I’ve tried changing the names also but that didn’t work as well, so I’m not sure what else to do.

1 Like

You are using startergui which is wrong, is this a server or localscriopt?

Your also missing () for the print .

It is a server also about the print, I tried and it works printing that with just the “”

Ok, use playergui instead of starterGUI. Playergui is in the player. You can’t do this via serverscripts so its best to use a remote function to check values

1 Like

I’m not sure how to access PlayerGui, where would I place the script and the value at?

1 Like

Use a local script instead, and the playergui is in the localplayer.

So I would put if game.players.localplayer.value.value == 1?

Why do these print functions doesn’t have brackets?

Where would I put the local script also?

I’m not sure but they work without them so that’s not the problem

I’m pretty sure you should include these brackets because sometimes the compiler can give random stupid errors from it.

Yes, add the parenthesis around print.


To access playerGui, you can do IN A LOCALSCRIPT:

game.Players.LocalPlayer.PlayerGui

But where would I put the value I don’t see anything named playergui

It does not really matter what you do with the print functions; It will work with or without the (). If you leave off the (), it’s less ascetically pleasing to the eyes; PlayerGui only appears when a player instance is added to the game.

So, for example, if I do Player.PlayerGui will get the PlayerGui of that player.

Also for your conditional, what are you trying to achieve?

I’m trying to make it so something changes if the value is “1 etc”
but when everything else worked and the values changed in the value correctly that was in the startergui
but the if statement did not
Also, where would I even add the value like how would I do it
game.Players.LocalPlayer.Instance.new(“NumberValue”) ???

What is the end goal of what your trying to do?

I’m trying to make a XP bar so every time you kill a NPC it changes the value of the number value, everything works the NPC script where it changes the value

Now I made a GUI where its like a progress bar and I want it to move every time the value changes to a number + the original number , that worked also, but the only thing that didn’t was the if statement that’s why you can see I tested it out with prints I put 2 prints top and bottom the top runs but the bottom doesn’t which means the if statement is not running, because the 2nd print is in the bottom of it and of my understanding I’m pretty sure it runs top to bottom.

print functions doesn’t requires brackets :smiley:
neither warn

So you cannot handle this on the client-side due to client-server ownership. you Would need to use a server script and fire the client with the needed information. However to keep track of this data I would personally use a table because it’s less messy. However, if you want to use instances you can. But you would need to simply increase the number or table index value by whatever the increment is, then fire the client to update the UI. You can have the UI calculations on server or client, it really depends on how you want to do it. Just as long as the server is handling the data and the client is just displaying the data.