My script has an error (W001: Unknown global 'Player'). I'm trying to make a script where you say "open" and it opens a door (takes collisions off a part). It works, but I'm trying to make it only work for a player with a certain rank or higher in a group.
This is the script:
-- SETTINGS --
GroupID = 4546303
Rank = 255
NonRank = 2
-- SCRIPT --
function onChatted(msg, recipient, speaker)
local source = string.lower(speaker.Name)
msg = string.lower(msg)
if (msg == "open") then
if Player:GetRankInGroup(GroupID) >= Rank then -- this is the line with the error: W001: Unknown global 'Player'
end
game.Workspace.Part.CanCollide = false
end
end
function onPlayerEntered(newPlayer)
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
end
game.Players.ChildAdded:connect(onPlayerEntered)
Can anyone help me with this?

5 comments
"Player" doesn't exist yet. If it's a local script, you can use game.Players.LocalPlayer
It still isn't working for some reason.
Is this a local script or a normal server script. If its local define local player by syaing "local Player = game.Players.LocalPlayer. If its server script
It looks like you may just need "speaker" instead of "Player".
It worked, thank you so much!