Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I get players Humanoid in a server script?

I'm making a game and its basically a survival game and I'm trying to make when the player dies the timer stops but I can't get there humanoid, This is a Server Script

My Script

local function roundTimer()
	while wait() do
		for i = intermissionLength, 1, -1 do
			InRound.Value = false
			wait(1)
			Status.Value = "Intermission: ".. i .." seconds left!"
		end
		for i = roundLegnth, 1, -1  do
			InRound.Value = true
			wait(1)
			Status.Value = "Survive for: ".. i .." seconds left!"
			player.Character.Humanoid.Died:Connect(function()
				
			end)
		end
	end
end

spawn(roundTimer())

4 comments

0

You cannot get the local player through scripts. You either need to use remote events or get the player through a touched event or something like that. I would recommend doing this in local script. And using remote events to handle on the server.

0

xD

0

That doesn't help me sorry

0

You can use Bindable Event/Function - it's basically two server scripts interacting with each other. In short, once the player dies, the server sends a message to another server script, and it acknowledges the message.

1 answer

Read the following, and attempt to add it in your code:

game.Players.PlayerAdded:Connect(function(player)

local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character.Humanoid

end)

Yes, it's that simple!

This discussion is preserved as it was. New answers, comments, and votes are closed.