Hi, I'm trying to make an ability for a sword, where it creates a bubble, and when people walk into it, they freeze. Then after, they unfreeze. The thing is, though, the player doesn't unfreeze for some reason, but the code before it does run? Help would be much appreciated.
Here is the code:
local Damage = 5
local TweenService = game:GetService("TweenService")
local frozen = Instance.new("BoolValue")
frozen.Name = "Frozen"
frozen.Value = false
game.ReplicatedStorage.IceBoom.OnServerEvent:Connect(function(player)
local char = player.Character
local part = game.ServerStorage.Bubble
local clone = part:Clone()
local Tweeninformation = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.In)
local TweenGoal = {Size = Vector3.new(47.333, 47.333, 47.333)}
local TweenAnimation = TweenService:Create(clone,Tweeninformation,TweenGoal)
local TweenGoal2 = {Size = Vector3.new(0.667, 0.667, 0.667)}
local TweenAnimation2 = TweenService:Create(clone,Tweeninformation,TweenGoal2)
clone.Parent = game.Workspace
clone.Position = char.HumanoidRootPart.Position
wait(.3)
clone.Explosion:Play()
clone.Ice:Play()
wait(0.2)
game.ReplicatedStorage.Boom:FireAllClients()
TweenAnimation:Play()
clone.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name ~= player.Name then
hit.Parent.HumanoidRootPart.Anchored = true
frozen.Parent = hit.Parent
end
end
end)
local hit = 0
while hit <= 5 do
wait(1)
hit = hit + 1
for i,v in pairs(game.Players:GetPlayers()) do
local char = v.Character
if char:FindFirstChild("Frozen") then
char.Humanoid:TakeDamage(Damage)
end
end
end
for i,v in pairs(game.Players:GetPlayers()) do
local char = v.Character
if char:FindFirstChild("Frozen") then
char.Frozen:Destroy()
char:FindFirstChild("HumanoidRootPart").Anchored = false
print("Unanchored")
end
end
TweenAnimation2:Play()
wait(1)
clone:Destroy()
end)

3 comments
Does it print "Unanchored"?
Yes.
It also says this for the error: "The Parent property of Frozen is locked, current parent: NULL, new parent Player1" Player1 is for when im doing the test with multiple players