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

How do I fix Sit : param is not a Humanoid or humanoid is dead?

Asked by 4 years ago
-- In a server script inside ServerScriptService.

local players = game:GetService("Players") -- Players service
local seat = workspace:WaitForChild("MainSeat") 

players.PlayerAdded:Connect(function(plr)
  local char = plr.Character or plr.CharacterAdded:Wait()
  local hum = char:FindFirstChildOfClass("Humanoid") -- The Humanoid

  seat:Sit(hum);
end)

That is the code I used that someone helped me write. it's supposed to make a player sit down when they join but I get this error please help me fix this and anymore errors you can spot thanks :)

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Try adding a wait() and see if it fixes it.

-- In a server script inside ServerScriptService.

local players = game:GetService("Players") -- Players service
local seat = workspace:WaitForChild("MainSeat") 

players.PlayerAdded:Connect(function(plr)
  local char = plr.Character or plr.CharacterAdded:Wait()
  local hum = char:FindFirstChildOfClass("Humanoid") -- The Humanoid
  wait(0.5)
  seat:Sit(hum);
end)

0
Thanks :) koviddev 29 — 4y
0
No problem. xInfinityBear 1777 — 4y
0
If the Humanoid is in NoneState, sitting won't work. Here waiting fixes it, because in that time the state changes. A more robust option instead of waiting would be to use the humanoid.StateChanged event to wait for the NoneState to end. sudachipapa 5 — 4y
Ad

Answer this question