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

HumanoidRootPart won't unanchor for some reason?

Asked by 3 years ago

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)
0
Does it print "Unanchored"? NotThatFamouss 605 — 3y
0
Yes. DriBowser 55 — 3y
0
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 DriBowser 55 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

After doing a bit of research, the instance seems to be garbage-collected. Garbage collection is a process to clear up memory if it is no longer being used. A way to counter this is to parent the instance to an existing instance immediately.

0
So like I parent it to the player's char immidiately? If so, that would made the script not work as intended. Sorry if I'm misunderstanding DriBowser 55 — 3y
0
You can parent it somewhere else, like ServerStorage. NotThatFamouss 605 — 3y
0
Ok thanks, I'll try it! DriBowser 55 — 3y
0
I'm still getting the same error message. Is it because i still parent the value to the player after? DriBowser 55 — 3y
View all comments (2 more)
0
Can you tell me which line did the error told you? It should be telling you the line of scripts that broke. If you are able to, hit me up on Discord so that we can make messaging easier. Ayaya#3692  NotThatFamouss 605 — 3y
0
sure! My user is The Gojira. DriBowser 55 — 3y
Ad

Answer this question