I am trying to make a script that when a character opens a door, it opens for the entire server. So i made it go through a server event, with the doorName value as the name of the door. but whenever I run this script:
local function openDoor(player, doorName) doorName.Humanoid:Destroy() end
the output says that "Humanoid" is a nul value, when there definitely a humanoid in the model.
doorName is set to the value of a string value with the location of the door model, I don't know if that has anything to do with it or not.
Why you do doorName.Humanoid
instend of player.Character.Humanoid
, the player is contain the character which is a model that contain humanoid.
Simple the players Character did not load all the way when it ran so it returned nil. Here's a fix! as well I do not know why you had doorName for the humanoid. You can use player as for getting this. Just wanted to say as well, DO NOT USE HUMANOIDS FOR DOORS AS THEY ARE VERY EXPLOITABLE EVEN THOUGH FILTERING ENABLED IS ON
local function openDoor(player, doorName) local char = player.Character or player.CharacterAdded:Wait() char:WaitForChild("Humanoid"):Destroy() end
if you want it that way for using a humanoid in the door here I guess... Also change the doorname to the models parent like "game.Workspace.door"
local function openDoor(player, doorName) local humanoid = doorName.Humanoid or doorName:WaitForChild("Humanoid") humanoid:Destroy() end