How to freeze a player?

Ok so, i have this magic move im making, and it throws out a shockwave right.
ok so I was wondering how I would clone a part to another player via on touched
and make them not able to move.
Basically how would I encase someone in ice and make it where they cant move then it deletes the ice and returns back to normal after a certain amount of time
Im not asking for a full script, just an example or what i need to know.

– Edit: also need to know how to do this without encasing the player who is using the move in the ice.

8 Likes

You can anchor all their body parts, or you can set their Humanoid’s WalkSpeed and JumpPower to 0, then restore them once you want to unfreeze the player. I would personally anchor all their body parts so you do not have to save their JumpPower and WalkSpeed, and if you have a sprinting key it won’t cause issues.

7 Likes

how would i make the part clone into a player on touched without cloning it into the player who presses the key that is used to activate the script

1 Like

Check if the character you’re freezing belongs to the player who made the move.

You can use game.Players:GetPlayerFromCharacter to get the actual player the attack is supposed to injure.

1 Like

This forum isn’t for jokes, it’s for helping people.

15 Likes

This should help

code


local IceBlock = Instance.new("Part")
IceBlock.BrickColor = BrickColor.new("Baby blue")
IceBlock.Size = Vector3.new(5, 7, 5)
IceBlock.Transparency = 0.5
IceBlock.Anchored = true

local Frozen = {} -- we will use this to store all of our frozen characters

function CharAnchor(Character, AnchorBool) -- anchor will be true or false
	for _, CharacterPart in pairs(Character:GetChildren()) do
		if CharacterPart:IsA("BasePart") then -- if the child is a basepart so we don't try to anchor scripts etc and get an error
			CharacterPart.Anchored = AnchorBool
		end
	end
end

function FreezeCharacter(Character)
	if not Frozen[Character] then -- if the Character isn't already frozen

		CharAnchor(Character, true) -- anchor the character
		
		local IceBlockClone = IceBlock:Clone()
		IceBlockClone.Parent = workspace
		IceBlockClone.CFrame = Character.PrimaryPart.CFrame -- move the IceBlock to the character
		
		Frozen[Character] = IceBlockClone -- index the character with the new IceBlock
		
	end
	
end

function UnFreezeCharacter(Character)
	local FrozenCheck = Frozen[Character] -- Checks if the Character is frozen
	if FrozenCheck then 
		FrozenCheck:Destroy()
		CharAnchor(Character, false)
		FrozenCheck = nil
	end
end

wait(10)
FreezeCharacter(game.Workspace.Quoteory) 
wait(2.5)
UnFreezeCharacter(game.Workspace.Quoteory) 
``
20 Likes

This sounds like this would be something executed in a tool. In this case, you would have to use RemoteEvents and think of a smart Server-Client model.


A suggestion I have for your model is to have a parallel system: Have the client run basically the same code as there server so that

  1. The client can have a smooth experience and not experience “input lag”
  2. Game is resistant to exploiters (as if you do the hit checking on the client and pass a name an exploiter can pass any old name and error your script or, worse, freeze people at their will)

@Quoteory has some good code on actually freezing the player, but this post is just to get you thinking of executing that code securely and correctly.

2 Likes

Clone an ice block and CFrame it to the character, then anchor their HumanoidRootPart, or set their walkspeed and jumppower to 0

1 Like

Sorry to revive this but, this should be recorded somewhere. I was digging in the wiki once to solve this exact problem. You can actually do this by doing:

function randomThing()
	return Enum.ContextActionResult.Sink
end

contextActionService:BindAction("freezeMovement",randomThing,false,unpack(Enum.PlayerActions:GetEnumItems()))

To allow the character to move again, you do:

ContextActionService:UnbindAction("freezeMovement")

I believe a while ago this was posted by TheGame101 but, I’m not too sure.

13 Likes