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

Can someone help me fix this?

Asked by 10 years ago
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

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

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.

0
Im still having a problem where both of the values are being put into a single character Chaserox 62 — 10y
Ad

Answer this question