I got it to work where the block spawns on me and I’m trapped in the ice block but the ice block won’t delete itself or dissapear. And if I manually delete it my character is stuck without the movement reenabled
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")
local ICEBLOCK_NAME = "IceBlock"
local FREEZE_TIME = 5
local TrapSound = ReplicatedStorage:FindFirstChild("IceTrapSound")
local PopSound = ReplicatedStorage:FindFirstChild("IcePopSound")
local PopParticle = ReplicatedStorage:FindFirstChild("IcePopParticle")
local function freezePlayer(character)
local humanoid = character:FindFirstChildOfClass("Humanoid")
local torso = character:FindFirstChild("Torso")
if not humanoid or not torso then return end
if character:FindFirstChild("IsFrozen") then return end
local freezeTag = Instance.new("BoolValue")
freezeTag.Name = "IsFrozen"
freezeTag.Parent = character
print("Freezing player: " .. character.Name)
-- Clone IceBlock
local iceClone = ServerStorage:FindFirstChild(ICEBLOCK_NAME)
if not iceClone then
warn("IceBlock not found in ServerStorage!")
freezeTag:Destroy()
return
end
iceClone = iceClone:Clone()
iceClone.Parent = workspace
local middle = iceClone:FindFirstChild("Middle")
if not middle then
warn("IceBlock is missing Middle part!")
iceClone:Destroy()
freezeTag:Destroy()
return
end
iceClone.PrimaryPart = middle
iceClone:SetPrimaryPartCFrame(torso.CFrame)
-- Trap sound
if TrapSound then
local ts = TrapSound:Clone()
ts.Parent = torso
ts:Play()
Debris:AddItem(ts, 3)
end
-- Freeze movement
local originalWalk = humanoid.WalkSpeed
local originalJump = humanoid.JumpPower
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
-- Wait freeze duration
wait(FREEZE_TIME)
print("Unfreezing player: " .. character.Name)
-- Pop particle
if PopParticle then
local p = PopParticle:Clone()
p.CFrame = middle.CFrame
p.Parent = workspace
p.Enabled = true
Debris:AddItem(p, 2)
end
-- Pop sound
if PopSound then
local ps = PopSound:Clone()
ps.Parent = torso
ps:Play()
Debris:AddItem(ps, 3)
end
-- Destroy IceBlock
if iceClone and iceClone.Parent then
iceClone:Destroy()
end
-- Restore movement
humanoid.WalkSpeed = originalWalk
humanoid.JumpPower = originalJump
freezeTag:Destroy()
end
-- Connect Touched safely
script.Parent.Touched:Connect(function(hit)
local character = hit.Parent
if character and character:IsA("Model") then
freezePlayer(character)
end
end)