I have a script that makes the player's arms and head look to where the mouse is pointing. It was working fine before, but after I added some stuff to make sure it doesn't happen while the player is opening a door, I got an error that says "doorOpening is not a valid member of player" or something like that, even though it clearly was and I was able to use it in other scripts. Why do I get this error?
local RunService = game:GetService("RunService") local player = game.Players.LocalPlayer local bool = Instance.new("BoolValue",player) bool.Name = "doorOpening" RunService.Stepped:connect(function() local character = player.Character local mouse = player:GetMouse() local dy = mouse.Y - mouse.ViewSizeY / 2 local dx = mouse.X - mouse.ViewSizeX / 2 if character and (mouse.x <= mouse.viewSizeX / 2) then if (player.doorOpening == false) then character.Head.Neck.Transform = character.Head.Neck.Transform * CFrame.Angles(math.atan2(dy, dx) + math.rad(180), 0, 0) character.LeftUpperArm.LeftShoulder.Transform = character.LeftUpperArm.LeftShoulder.Transform * CFrame.Angles(math.atan2(dy, dx) + math.rad(180), 0, 0) character.RightUpperArm.RightShoulder.Transform = character.RightUpperArm.RightShoulder.Transform * CFrame.Angles(math.atan2(dy, dx) + math.rad(180), 0, 0) end else if (player.doorOpening == false) then character.Head.Neck.Transform = character.Head.Neck.Transform * CFrame.Angles(-(math.atan2(dy, dx)), 0, 0) character.LeftUpperArm.LeftShoulder.Transform = character.LeftUpperArm.LeftShoulder.Transform * CFrame.Angles(-(math.atan2(dy, dx)), 0, 0) character.RightUpperArm.RightShoulder.Transform = character.RightUpperArm.RightShoulder.Transform * CFrame.Angles(-(math.atan2(dy, dx)), 0, 0) end end end)
local RunService = game:GetService("RunService") local player = game.Players.LocalPlayer local bool = Instance.new("BoolValue") bool.Name = "doorOpening" bool.Value = false bool.Parent = player RunService.Stepped:connect(function() local character = player.Character local mouse = player:GetMouse() local dy = mouse.Y - mouse.ViewSizeY / 2 local dx = mouse.X - mouse.ViewSizeX / 2 if character and (mouse.x <= mouse.viewSizeX / 2) then if (player.doorOpening.Value == false) then character.Head.Neck.Transform = character.Head.Neck.Transform * CFrame.Angles(math.atan2(dy, dx) + math.rad(180), 0, 0) character.LeftUpperArm.LeftShoulder.Transform = character.LeftUpperArm.LeftShoulder.Transform * CFrame.Angles(math.atan2(dy, dx) + math.rad(180), 0, 0) character.RightUpperArm.RightShoulder.Transform = character.RightUpperArm.RightShoulder.Transform * CFrame.Angles(math.atan2(dy, dx) + math.rad(180), 0, 0) end elseif (player.doorOpening.Value== false) then character.Head.Neck.Transform = character.Head.Neck.Transform * CFrame.Angles(-(math.atan2(dy, dx)), 0, 0) character.LeftUpperArm.LeftShoulder.Transform = character.LeftUpperArm.LeftShoulder.Transform * CFrame.Angles(-(math.atan2(dy, dx)), 0, 0) character.RightUpperArm.RightShoulder.Transform = character.RightUpperArm.RightShoulder.Transform * CFrame.Angles(-(math.atan2(dy, dx)), 0, 0) end end end)
I'm guessing the reason why it was not working was because of the fact that you forgot to put .Value.