local Players = game:GetService("Players") groupID = 3237760 rankID = 10 local TweeenService = game:GetService("TweenService") local door1 = script.Parent:WaitForChild("Door1") local door2 = script.Parent:WaitForChild("Door2") local tweenfor = TweenInfo.new( 0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0 ) local door1Open = {CFrame = CFrame.new(-78.9, 4.1, -164.2)} local door2Open = {CFrame = CFrame.new(-78.9, 4.1, -172.45)} local door1Close = {CFrame = CFrame.new(-78.9, 4.1, -167)} local door2Close = {CFrame = CFrame.new(-78.9, 4.1, -169.75)} local tween1open = TweeenService:Create(door1,tweenfor,door1Open) local tween1close = TweeenService:Create(door1,tweenfor,door1Close) local tween2open = TweeenService:Create(door2,tweenfor,door2Open) local tween2close = TweeenService:Create(door2,tweenfor,door2Close) script.Parent.Detector1.Touched:connect(function(hit) local plr = Players:GetPlayerFromCharacter(hit.Parent) if plr:GetRankInGroup(groupID) == rankID then tween1open:Play() tween2open:Play() wait(2) tween1close:Play() tween2close:Play() end end) script.Parent.Detector2.Touched:connect(function(hit) local plr = Players:GetPlayerFromCharacter(hit.Parent) if plr:GetRankInGroup(groupID) == rankID then tween1open:Play() tween2open:Play() wait(2) tween1close:Play() tween2close:Play() end end)
Located in a model, server script.
What this script does is it makes a sliding door open if a player is an admin in a group. It gives me an error saying the plr is a nil value. Any help would be appreciated!
Getting the parent of "hit" will not point you to the player all the time. Sometimes "hit" refers to the handle of an accessory, and the parent of it is the accessory itself. Detect if the part is part of the players body, or a hat.