Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why cant i change the parent of the values?

tried to get a wait in there incase there were just some stuff that had to load in server script:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(character)
		wait(5)
		for i,v in pairs(character.Animate:GetChildren()) do
			if v:IsA("StringValue") then
				v.Parent = character.animate
				print(v.Name)
			end
			if v:IsA("BindableFunction") then
				v.Parent = character.animate
				print(v.Name)
			end
			if v:IsA("NumberValue") then
				v.Parent = character.animate
				print(v.Name)
			end
			character.Animate:Destroy()
		end
	end)
end)

error: The Parent property of swimidle is locked, current parent: NULL, new parent animate this makes my edited version of animate script not work, Infinite yield error Workspace.world_kiIIer.animate:WaitForChild("PlayEmote")' Workspace.world_kiIIer.animate', Line 772 had to make another version of it because i added a god mode script that changes the name of the humanoid in order to not get killed

For some reason when i did

for i,v in pairs(character.Animate:GetChildren()) do
v.Parent = character.animate
end

nothing happened at all

1 answer

✓ Accepted answer

You are getting this error because on the first loop you are already destroying the Animate script. Thus all of the values are destroyed and you get an error. To fix this simply put the destroy line outside of the for loop right after you parent everything.

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(character)
        wait(5)
        for i,v in pairs(character.Animate:GetChildren()) do
            if v:IsA("StringValue") then
                v.Parent = character.animate
                print(v.Name)
            end
            if v:IsA("BindableFunction") then
                v.Parent = character.animate
                print(v.Name)
            end
            if v:IsA("NumberValue") then
                v.Parent = character.animate
                print(v.Name)
            end
        end
        character.Animate:Destroy()
    end)
end)

1 comment

0

changed up the code a bit but u were right about putting the destroy() outside the loop, didnt think about that

This discussion is preserved as it was. New answers, comments, and votes are closed.