[SOLVED] Touched Event not working Between Players

Hello, I’m trying to make a hide and seek game where if the seeker touches the player, the player dies
I’m using Touched event that works for NPCs but not other players

game.ReplicatedStorage.StartRound.OnServerEvent:Connect(function(player)
	local Players = game:GetService("Players"):GetChildren()
	local Seeker = player.Name
	local PlayerCount = #Players - 1
	local Round = false
	local Status = "Blank"
	
	player.Character.HumanoidRootPart.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") and Round == true then
			print("Player Hit")
	
			local Player = hit.Parent
			
			Player.Alive.Value = false
			Player.Humanoid.Health = 0

			game.ReplicatedStorage.Announcement:FireAllClients(Player)

			PlayerCount -= 1
			print(PlayerCount.." Players Left")

			if PlayerCount == 1 then
				for i,v in pairs(Players) do
					if v.Alive.Value == true then
						Status = v.Name.." has won!"
						game.ReplicatedStorage.StatusUpdate:FireAllClients(Status)
					end
				end
			end
		end
	end)
	
	game.ReplicatedStorage.Menu:FireAllClients()
	
	wait(1.5)
	
	for i,v in pairs(Players) do
		
		local Spawns = game.Workspace.Spawns:GetChildren()
		local RandomSpawn = math.random(#Spawns)
		local SpawnLocation = Spawns[RandomSpawn]
		
		v.Character.HumanoidRootPart.CFrame = SpawnLocation.CFrame
		
		if v.Name == Seeker then
			v.Seeker.Value = true
			v.Character.Humanoid.WalkSpeed = 0
		else
			v.Hider.Value = true
			v.Alive.Value = true
		end
		
	end
	
	wait(1.6)
	
	game.ReplicatedStorage.Seeker:FireClient(player)
	
	for count = 5, 0, -1 do
		wait(1)
		
		game.ReplicatedStorage.Timer.Value = count
	end
	
	Status = "Seeker has been Released!"
	game.ReplicatedStorage.StatusUpdate:FireAllClients(Status)
	
	Round = true
	
	player.Character.Humanoid.WalkSpeed = 16
end)

When the Seeker touches another player after the round has started, nothing happens. But oddly, it works when the seeker touches a Dummy/NPC, anybody know why?

Have you trie making it fire a RemoteEvent to the Server and then fire another one to the Client of the Player that has to die?

Not sure what you mean, this script is a server script

I’ve messed with this stuff a little in the past, have you at all experimented with Humanoid.Touched? It seems to be a little more reliable for stuff like this, but that was years ago. Worth investigating though!

Wait, from what I know the other Humanoid will not know he has to die unless you use a RemoteEvent if I’m not wrong

Why? This is inside a server script, that would only make sense if this was a local script. Not even sure how I would make a remoteevent work here.

That doesn’t seem to change anything.

Unfortunate, is it not firing the event period or is it just failing an if check?

Pretty sure it’s failing the if check. I added a print before the if statement and that works.

As you al can see I’m not a Progranmer so take every thgin with a grain of salt, I’m no expert, but why I mean is that because the Dummy doesn’t have a client and everything is accessible form the Server it can work, but maybe if it has a Client it doesn’t work?
You would implement the RemoteEvent just before you tell the Humanoid to die and then tell him to die fork another script?

1 Like

While this wasn’t directly the solution, you helped me realize there was another error in the script I didn’t catch. I forgot to use :GetPlayerFromCharacter when changing the value of alive

1 Like

Okay, yes sorry, I’m not a Programmer so I couldn’t really help :sweat_smile: , but I’m happy you were able to solve the problem! :smiley: