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

Freeze Character not working?

I am using the following code:


function FreezePlayer(player)
	local torso = player:FindFirstChild("Torso")
	if (torso) then
		torso.Anchored = true
	end	
end

function OnKillingStateStarted()
	UpdateGameState()
	if (repFreezable.Value and state == GameState.Chasing) then
		repFreezable.Value = false
		repGameState.Value = GameState.Killing
		-- Freeze all survivors.	
		contestants:ForEach(function(player)
			if (player ~= bloxxer) then
				FreezePlayer(player)
			end
		end)
		freezeTimer:Restart()
		freezeCooldownTimer:Restart()
	end
end

And the code does nothing. The little guys still walk around and ignore my code. I'm wondering if I should hit them.

: Tkdriverx Thanks for the reply.

I'm trying to pull out each player (default method) I use ForEach in other situations and it seems to work fine... The code below works fine for spawning.

	local useableSpawns = List(officeSpawns)
	players:ForEach(function(player)
		local character = player.Character
		if (character) then
			local humanoid = character:FindFirstChild("Humanoid")
			local torso = character:FindFirstChild("Torso")
			local spawn = useableSpawns:Choose()
			local spawnPos = spawn.Position
			if humanoid and torso then
				humanoid.Health = 100
				humanoid.WalkSpeed = 16
				torso.CFrame = CFrame.new(spawnPos.x, 5, spawnPos.z)
				 
				useableSpawns:Remove(spawn)
			end
		end
	end)

1 comment

1 answer

What is the :ForEach() method? Is this a method you created or are you trying to do a "default" method on a table?

And, I think you should hit them. Show them who's boss. :P

4 comments

0

See reply above

0

I don't think :ForEach is a valid method

0

Use in pairs. (for i, v in pairs(table) do)

0

Hmm.. Ok, I'll give it a try.

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