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

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

Asked by 6 years ago
Edited 6 years ago

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?

0
"Player" doesn't exist yet. If it's a local script, you can use game.Players.LocalPlayer Trew86 175 — 6y
0
It still isn't working for some reason. OrbitOps 34 — 6y
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 tonyv537 95 — 6y
0
It looks like you may just need "speaker" instead of "Player". aschepler 135 — 6y
0
It worked, thank you so much! OrbitOps 34 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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

0
It worked, thank you so much! OrbitOps 34 — 6y
Ad

Answer this question