If statement not changing after changing the value

Hey! I’ve been trying to change the CameraMode and mouse using scripts and if statements. However, whenever I change the value manually or use a script of the StringValue it won’t change. I’ve tried looking up ways to do it with attributes, but i’m not very familiar with them so I couldn’t figure it out. Is it just that Values are not used anymore or did I do something wrong scripting wise? I’ve looked at many forums and API references but none have seemed to work. Any help appreciated.

script is localscript
image

Have you try printing? Also change:

while true do
    -code
end

to:

while wait(2) do
    -code
end

It may work!

Edit: Use Boolean value instead of string value.

if script.FT.Value == false then
  -code
end

if script.FT.Value == true then
  -code
end

Printing is in the if statements. But i’ll try this and see if it works.

I’ve never tried boolean values before, the API reference explains very little on how it actually works. From the looks of things there’s no way to make the value False/True, how would I do this?

Boolean Value are like true and false. The “Value” that does not have a tick is false. The “Value” that has a tick is true.

ooohhh ok, let me see if I can get it to work.

So for the most part it seems to be working, kinda. I can change the value to change between and it will do so, but now when I have the mouse visible and the CameraMode classic, the mouse stays in the middle. Is there a way to fix this?

Your current code seems fine and should run. One thing I would change is:

UserInputService.MouseIconEnabled = script.FT.Value;

Since you can’t set a bool value (MouseIconEnabled is a bool) to a string. I don’t think it will error (should just default since you gave it the wrong value), so thats not the issue.

Can you show us how you change the value? Are you just going to the same script in StarterPlayerScripts and editting the value there?

Know that the actual script running isn’t the one you see in StarterPlayerScripts. The actual script will be cloned from StarterPlayerScripts into the players “PlayerScripts” folder when they join.

I’m aware that it moves into the PlayerScripts, but I have the script that will be changing the bool value in StarterGui, which moves to PlayerGui too. I haven’t written code for the changing of the value inside the StartButton script as I was mainly trying to fix this script.

image

Another thing should I be using a different method to change the cursor to be still and invisible to movable and visible? My game is a First Person game with no mouse, so I thought I would just change the CameraMode. Is their an easier way to do it, because if I switch between the two my mouse always remains in the middle and the CameraMode has been changed in my player.

Edit: forgot to mention that I will have the cursor visible when a gui is on screen and the gui takes up the whole screen.

instead of “False” maybe just put False? You can also use a bool value instead of a String value.

Yeah thats what someone told me to do and it worked for the most part. But my mouse cursor just stays in the middle when I switch from lockfirstperson and classic.

So your prints and printing now? When it switches back to classic you’ll have to zoom out (if you didn’t try that already).

1 Like

can i ask you why you are using an string value? did u tried Boolean Values?

Hey I managed to find a simpler method which is just the Modal under the TextButton properties. GuiButton | Roblox Creator Documentation

I did some digging and found this and it seems to be working perfectly now.

I’m going to mark glowing’s answer as a solution since that is the solution to the original question. But thanks for your help!