Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can someone help me fix this?

ro = Instance.new("StringValue")
 plyr = script.Parent
while true do
		
		wait()
	if game.workspace.Room1.Value == false then
		game.Workspace.Room1.Value = true
	
	ro.Value = "RoomA"
	ro.Name = "RoomA"
	ro.Parent = script.Parent
	script.Disabled = true
	wait(1)

	
	
	 if game.workspace.Room2.Value == false then
	game.Workspace.Room2.Value = true
	
	ro.Value = "RoomB"
	ro.Name = "RoomA"
	ro.Parent = script.Parent
	script.Disabled = true
	wait(1)
	end
end
end

What this script does or what its supposed to do is put a string value in the player that enters the game but currently only player1 is getting the value and player 2 doesent

NOTE the script is put inside of the player when they spawn



1 answer

✓ Accepted answer

If you want to run code inside a player that executes each time the player respawns, you should use a LocalScript. If the script does not need to be inside the player, use the CharacterAdded event. Also, since you're putting a new value inside the player each time they spawn, you will end up with a bunch of values inside the player.

Anyways, here is your main problem:

Let's say Room1 and Room2 are both set to false. When the code runs, we will pass the first if statement because Room1 == false. Then, we move on to the if statement that you placed inside the first if statement. Since Room2 == false, we set it to true.

Now, since both values are true, the code will not run again. On top of that, the script is Disabled, so it won't even try to run again!

Now, try to edit your code based on what I said, and come back if you need more help.

1 comment

0

Im still having a problem where both of the values are being put into a single character

This discussion is preserved as it was. New answers, comments, and votes are closed.