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?
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!
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?
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