Roblox Can't Tell If My Value Is True Or False Though CLEARLY Writing It In The Script

My script isn’t working and I can’t fix it

	for i, players in pairs(plr) do
				print("Reading Players")
		if players then	
					print("Is A Player")
			character = players.Character
		print("Found Character")
			if character then
						print("Character Is Here")
				if players.InMenu.Value ~= true then --this is the problem here
					print("Teleporting Players")
	players.Character:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(11.5, 28.5, -127.5)
					print("Teleport Success")
				else
					print("Still In Menu")
					table.remove(plr, i)
				end
			else
						print("Not Character")
				if not players then
					table.remove(plr, i)
					print("Not Player")
					end
			end
		end
	end

My problem is that the script always thinks the player is out of the menu, even when they are in the menu and the InMenu value is ticked SHOWING the script NOT TO TELEPORT THE CHARACTER!

EDIT: I just give up with this game, even the tutorials I watch don’t work.

EDIT 2: The video I have been basing my script off of is https://www.youtube.com/watch?v=1MappXJ51Oo&t=436s by AlvinBlox

2 Likes

What do you mean by this? I don’t even understand the script anyway because I am following a tutorial.

2 Likes

Oh wait nevermind. I didn’t quite frankly understand your code. Sorry, I will delete my reply.

2 Likes

Okay, try going to the console and checking for errors. You shouldn’t make a post on the developer forums without checking for errors on the output and/or trying to de-bug the code yourself.

2 Likes

There are no errors in the output and when I print the value in output it comes out as true (when in the menu).

It is the scripts fault.

2 Likes

i dont see any problems with the script, are you sure the script that sets the InMenu value to true and false is worknig correclty?

2 Likes

Have you tried

´´´
if players.InMenu.Value == false then

or

if not players.InMenu.Value then
´´´

2 Likes

image image
It is still teleporting me.

2 Likes

None of these worked…

2 Likes

The issue probably relies outside the code block since LUA wouldn’t suddenly not understand true and false.

Is InMenu being edited by a LocalScript? The client cannot change something in the server.

1 Like
for i, player in pairs(plr) do
   if player then
      local character = player.Character
      
      if character then
         if player.InMenu.Value == false then
            character.HumanoidRootPart.CFrame = CFrame.new(11.5, 28.5, -127.5)
         else
             table.remove(plr, i)
         end
      else
          table.remove(plr, i)
      end
   end
end

This should be an exact replica of your script but with correct indentations. I guess try this, it’s most likely gonna do the same action but without logging the stuff, but who knows.

1 Like

Yeah, it still teleported the character.

1 Like

Mini Madness - Roblox The game is here if you want to test it for yourself.

1 Like

I give up with the game, if anyone wants to help script then that’s fine but I cant even script a simple game myself so what is the point.

1 Like

I think the problem is in how your InMenu value is updated or modified, as far as i know any changes made to it by a LocalScript or within the Properties tab itself is undetected by the server so make sure that it is the server that changes the value before you do your checks.

2 Likes

If you give up, then you won’t be able to learn anything in scripting. Is there a line is your code that says:

players.InMenu.Value = false? If so, is it a Script or a LocalScript?

1 Like

Yeah. As I mentioned earlier, changes from the console (which the LocalScript is a part of) on server sided properties (ex. Players, workspace, etc.) will only be seen by the client. OP’s script (which I assume is server sided) doesn’t detect the change which is why the player is being teleported.

In order to change a value from the client to the server, you would have to use a RemoteEvent. However since OP is still new to coding, I wouldn’t recommend him to learn it.

2 Likes
  1. Did you print players.InMenu.Value?
  2. Do you have any script that changes the value of the Player’s InMenu InstanceValue?
  3. Is this teleportation of character handle locally or server-side? Either will do, but it is much more safe to do at the server.
1 Like

I’m pretty sure this worked, thanks!

3 Likes

Try using a remote event to change the value of InMenu