Destroy script broken

So I’ve made a morph script, and there’s another button I’m making which helps transform the player back.

It works, in that the player is made visible again, but the model with the rig inside the player is not desroyed.

(the thing that needs to be deleted is the moddel called Morph)

Anything past line 9 doesn’t work.
I’m still new, so it’s probably a simple error, either way thank you for any help.

(This is just in a localscript in a gui button)

local Player = game.Players.LocalPlayer
local Character = Player.Character
script.Parent.MouseButton1Click:Connect(function()

	for _,part in pairs(Player.Character:GetDescendants()) do
		if part:IsA('BasePart') or part:IsA('Decal') then
			part.Transparency = 0
		end
	end
	Player:FindFirstChild("HumanoidRootPart").Transparency = 1
	Player:FindFirstChild("Morph"):Destroy()
	Player.CustomAnimate:Destroy()
	Player.Animate.Enabled = true
end)



What exactly do you mean by “not work”? does nothing happen? does it give you an error?

No error messages, But essentially it can’t seem to find the ‘Morph’ model.

The transparency part of the script in the for loop functions

If it cant find the morph model, it should return a model saying something about being unable to find the child.

wait I just realized…

game.Players.LocalPlayer is the player object, so why are you using PLayer:FindFirstChild and not Character:FindFirstChild when the morph is in the character XD

1 Like

OHHH

Thank explains a lot.

Thank you, I’ll see if i can fix it up, I should be able to.

1 Like

Yeah, that was it. I usually miss something stupid like that. Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.