How do i make a player die when he is not sitting?

I want player to die when touches a brick and isn’t sitting, but what i’ve got so far doesn’t work.

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild(“Humanoid”)

function onTouched(hit)

if humanoid.Seated then
return
else
humanoid.Health = 0
end
end

script.Parent.Touched:connect(onTouched)

Hi! Are you talking about touching a part and they die for touching it? If so, here’s the script.

local Brick = script.Parent

local function PlayerTouched(Part)
	local Parent = Part.Parent
	if game.Players:GetPlayerFromCharacter(Parent) then
		Parent.Humanoid.Health = 0
	end
end

Brick.Touched:connect(PlayerTouched)

Is there any particular reason you are listening for a Touched event on the client?

If you switch to a server script you can use this:

local function onTouched(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if (player ~= nil and player.Character ~= nil and player.Character:FindFirstChild("Humanoid") ~= nil and not player.Character.Humanoid.Sit) then
		player.Character.Humanoid:TakeDamage(100)
	end
end

script.Parent.Touched:Connect(onTouched)

Works as a charm, thank you. I was testing some other ways in both local and regular script so got mixed up a bit.