TouchedEnded fires when player jumps

The TouchEnded function fires even when player jumps

Yes, that’s because the player’s parts (their legs) are no longer touching the part which was previously touched.

1 Like

This makes it harder because if I was trying to make a game that you have to step on the right colored part to not get eliminated how would i eliminate a player because they could jump and avoid

1 Like

What goes up, must come down. If the player state is free fall, set up an event to capture their location when they land (running state).

1 Like

You could just have the parts which were incorrect (shouldn’t be stood on) disappear or have their collisions disabled & then have a killing part below.

1 Like

I was thinking about using a table

1 Like

Yes, you could have several tables which records which players touched which part last.

1 Like
local players = game:GetService("Players")
local redPart = workspace.Red
local bluePart = workspace.Blue
local redPlayers = {}
local bluePlayers = {}

redPart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("HumanoidRootPart") then --is a player
		local player = players:GetPlayerFromCharacter(hit.Parent)
		table.insert(redPlayers, player)
		for i, v in pairs(bluePlayers) do
			if v == player then
				table.remove(bluePlayers, i)
			end
		end
	end
end)

bluePart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("HumanoidRootPart") then --is a player
		local player = players:GetPlayerFromCharacter(hit.Parent)
		table.insert(bluePlayers, player)
		for i, v in pairs(redPlayers) do
			if v == player then
				table.remove(redPlayers, i)
			end
		end
	end
end)
2 Likes