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

Am I doing this wrong?

Asked by 9 years ago
local group = {
    ["jameswowsmile"] = true;
    ["leslielol1234"] = true;
}

game.Players.PlayerAdded:connect(function(player)
    if group[player.Name] then 
        player.Chatted:connect(function(msg)
            --chatted code 
        end)
    end
end)


door = script.Parent --this is the door 

function onChatted(msg, recipient, speaker) 

-- convert to all lower case 

local source = string.lower(speaker.Name) 
msg = string.lower(msg) 

if (msg == "FloorClose") then 
door.CanCollide = false 
door.Transparency = 1

end 

end 

function onPlayerEntered(newPlayer) 
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end 

game.Players.ChildAdded:connect(onPlayerEntered) 

This is supposed to give two players (Jameswowsmile and Leslielol1234) permission to say a command that would make a floor disappear when you say "FloorClose". I tested this and it didn't work. What did I do wrong?

1 answer

Log in to vote
0
Answered by 9 years ago

Problems

  1. You need to add the chatted door thing inside the chatted thing
  2. You are comparing a lowercase to an uppercase(lowercase all the letters in FloorClose)

Final Product

local group = {
    ["jameswowsmile"] = true;
    ["leslielol1234"] = true;
}

game.Players.PlayerAdded:connect(function(player)
    if group[player.Name] then 
        player.Chatted:connect(function(msg)
            door = script.Parent
        if msg:lower() == "floorclose" then --LowerCased "FloorClosed"
            door.CanCollide = false 
            door.Transparency = 1
        end
        end)
    end
end)


Hope it helps!

0
Thank you! It works! However, on the 9th line, you forgot a local. Works after you put it on! BringMeTacos 20 — 9y
Ad

Answer this question