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

How do I open a door if a player is on the correct team?[solved]

Asked by
Webm07 43
7 years ago
Edited by Goulstem 7 years ago
function Active(Touched)
if Touched.Parent:FindFirstChild("Humanoid") then      ----== game.Teams.Cops then
    local Plr = game.Players:GetPlayerFromCharacter(Touched.Parent.Humanoid)
    if Plr.Team == game.Teams.Cops then
    script.Parent.OpenDoor:Fire()

else
    if script.Parent.Deny.IsPlaying == false then script.Parent.Deny:Play() end
end
end
end
script.Parent.Touched:connect(Active)

When I try it, it dosen't work. I get an error:

`11:17:53.237 - Workspace.YardDoor.Sensor.Main:4: attempt to index local 'Plr' (a nil value)

11:17:53.239 - Stack Begin

11:17:53.240 - Script 'Workspace.YardDoor.Sensor.Main', Line 4

11:17:53.241 - Stack End`

1
You are using GetPlayerFromCharacter with the humanoid instead of the actual character, instead of Touched.Parent.Humanoid use Touched.Parent Vulkarin 581 — 7y
0
Thank you! Solved! Webm07 43 — 7y

Answer this question