Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

-- 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

✓ Accepted answer

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)

3 comments

0

Thanks :)

0

No problem.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.