Not sure why this is happening any ideas how to fix?

Hello (again), i’m having a few more issues with the place.
So my problem is my scripts aren’t working properly. (they are working but not the way they should) so what i’'m trying to do is make a guessing game so when you say something in chat something would happen. (example you say a color and a door would open) but when i say “white” the other doors open, also anything said in chat opens all the doors. Here is the script:
local door = script.Parent

door.Anchored = true

function open()

door.Transparency = 1

door.CanCollide = false

wait(5)

door.Transparency = 0

door.CanCollide = true

end

game.Players.PlayerAdded:Connect(function(p)

p.Chatted:Connect(function(msg)

    local message = msg:lower()


    if message == "White" or "white" then

        open()

end
end)
end)

Note: all scripts are the same in each door
is there anyway to fix this?

It should be function() not function§

Yep i know when ever i post that script it happens
in studio it says function()

Also, I recommend doing

message:lower() instead of different capitalisation variants.

its already in there as well as the “main” versions

There’s your problem. Doing or "white" will always be true because it’s not equal to nil, so you need to put if message == "white" then

ummmm now it now longer opens at all?

Show me your new script so I can see what the problem is.

local door = script.Parent

door.Anchored = true

function open()

door.Transparency = 1

door.CanCollide = false

wait(5)

door.Transparency = 0

door.CanCollide = true

end

game.Players.PlayerAdded:Connect(function(p)

p.Chatted:Connect(function(msg)

    local message = msg:lower()


    if message == "White" then

        open()

end
end)
end)

You’re already doing msg:lower() so it will all be in lower case, so instead of “White”, do “white”.

Ok so the door is opening again now the second problem all the doors open. would a fix to be changing the script to the working one

You said that all doors have the same script in them, in different scripts just change the keyword to something else.

1 Like

Thank you for your help!
(30charss)

1 Like