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

Head of the player does not exist?

Asked by 4 years ago

I made a script that when the player spawns, a brick spawns, and is welded to the players head. When I run the script below, the output says that player.Head does not exist.

local remoteEvent = game.ReplicatedStorage.remoteEvent

remoteEvent.OnServerEvent:Connect(function(player)
  local head = player.Head

  local humanoid = player.Character.Humanoid

  local part = Instance.new("Part")

  part.Name = part
  part.Anchored = true
  part.Parent = workspace

  local weld = Instance.new("Weld")

  weld.Parent = game.Workspace.part

  weld.Part0 = head
  weld.Part1 = part

Can someone please tell me what's wrong? I can't seem to find out because when I run the game and look at my player in Workspace, one of the children is the Head. Also pointing out any other things I did wrong would be very well appreciated.

1 answer

Log in to vote
1
Answered by
rabbi99 714 Moderation Voter
4 years ago

The player doesn't hold "Head". The character does so:

local remoteEvent = game.ReplicatedStorage.remoteEvent

remoteEvent.OnServerEvent:Connect(function(player)
  local head = player.Character.Head

  local humanoid = player.Character.Humanoid

  local part = Instance.new("Part")

  part.Name = part
  part.Anchored = true
  part.Parent = workspace

  local weld = Instance.new("Weld")

  weld.Parent = game.Workspace.part

  weld.Part0 = head
  weld.Part1 = part
0
Thanks! packayee 13 — 4y
Ad

Answer this question