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.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?
Fondatix
(Fond)
January 5, 2020, 8:01am
#2
It should be function() not function§
Yep i know when ever i post that script it happens
in studio it says function()
Fondatix
(Fond)
January 5, 2020, 8:02am
#4
Also, I recommend doing
message:lower()
instead of different capitalisation variants.
its already in there as well as the “main” versions
Fondatix
(Fond)
January 5, 2020, 8:04am
#6
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?
Fondatix
(Fond)
January 5, 2020, 8:07am
#8
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.Chatted:Connect(function(msg)
local message = msg:lower()
if message == "White" then
open()
end
end)
end)
Fondatix
(Fond)
January 5, 2020, 8:08am
#10
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
Fondatix
(Fond)
January 5, 2020, 8:12am
#12
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