Touched event doesnt fire when sitting?

Im trying to fire to a remote event that makes parts visible. The issue is that when the player is sitting down it doesnt fire. When standing: bandicam 2020-08-17 08-54-02-173.mp4 - Google Drive
When sitting: bandicam 2020-08-17 08-57-08-255.mp4 - Google Drive
The first one fires when I stand up, but when I sit down nothing fires when I touch the part.
Heres my server code:

local players = game:GetService("Players")
local debounce = false

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
		debounce = true
		local player = players:GetPlayerFromCharacter(hit.Parent)
		local Fire1 = game.ReplicatedStorage.Jumpscare2
		Fire1:FireClient(player)
	end
end)

Here is my client code:

local FIred = game.ReplicatedStorage.Jumpscare2
local debounce = false

FIred.OnClientEvent:Connect(function()
	if debounce == false then
		for i,v in pairs (workspace.Train1.Model:GetDescendants()) do
			if v:IsA("Part") or v:IsA("Decal") then
				v.Transparency = 0
				script.Parent.Scream:Play()
			end
		end
		wait(2)
		local function lights(value)
			for i,v in pairs(game.Workspace.Train1:GetDescendants()) do
				if v:IsA("SpotLight") or v:IsA("PointLight") then
					v.Enabled = value
				end
			end
		end
		lights(false)
		game.StarterGui.Electricity_surge:Play()
		wait(3)
		game.Workspace.Train1.Model:Destroy()
		lights(true)
		game.StarterGui.Electricity_Up:Play()
	end	
end)

I dont think this has to do with anything but I put my code here just in case.

1 Like

If for some reason the Touched event isn’t working, you can always use the GetPropertyChangedSignal to detect a change in the occupant. This is probably more useful for you since you don’t have to check if a touched brick is actually part of a character.

An Example

local Players = game:GetService("Players")
local debounce = false

script.Parent:GetPropertyChangedSignal("Occupant"):Connect(function(newHumanoid)
    local PlayerFromHumanoid = Players:GetPlayerFromCharacter(newHumanoid.Parent)
    if PlayerFromHumanoid then
        -- Fire when player is sitting.
    end
end)
3 Likes