Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Freeze Character not working?

Asked by 10 years ago

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 answer

Log in to vote
0
Answered by
Tkdriverx 514 Moderation Voter
10 years ago

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

0
See reply above robokingfish 26 — 10y
0
I don't think :ForEach is a valid method Tkdriverx 514 — 10y
0
Use in pairs. (for i, v in pairs(table) do) Tkdriverx 514 — 10y
0
Hmm.. Ok, I'll give it a try. robokingfish 26 — 10y
Ad

Answer this question