function touched(body) body.HumanoidRootPart.Touched:Connect(function(hit) local otherPlayer = game.Players[hit.Parent.Name] print(otherPlayer) if otherPlayer == game.ServerScriptService.RoundHandler.EnemyPlayerName.Value then script.Parent.Humanoid.Health = 0 end end) end game.Players.PlayerAdded:Connect(function(newPlayer) newPlayer.CharacterAdded:Connect(touched) end)
the player is supposed to be killed when the player with enemyplayername name touches the person. the script doesn't work.
You're comparing an instance of a player to a string that supposedly contains their name.
So, instead of doing this:
if otherPlayer == EnemyPlayerName.Value then script.Parent.Humanoid.Health = 0 end
You do this:
if otherPlayer.Name == EnemyPlayerName.Value then script.Parent.Humanoid.Health = 0 end
Think of it like the concept of like terms in math. You can't compare unlike terms in math, just as you can't compare unlike data types in computer programming.