Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[SOLVED] My script has an error (W001: Unknown global 'Player'). Can anyone help?

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

0

"Player" doesn't exist yet. If it's a local script, you can use game.Players.LocalPlayer

0

It still isn't working for some reason.

0

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

0

It looks like you may just need "speaker" instead of "Player".

0

It worked, thank you so much!

1 answer

✓ Accepted answer

Player doesn't exist. I think you meant to put "speaker"

1 comment

0

It worked, thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.