When I try to morph someone, it teleports them into it and they can't move

function onTouched(hit)
	if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Chest1") == nil then
		local g = script.Parent.Parent.Chest:clone()
		g.Parent = hit.Parent
		local C = g:GetChildren()
		for i=1, #C do
			if C[i].className == "Part" or C[i].className == "UnionOperation" or C[i].className == "WedgePart" or C[i].className == "MeshPart" then
				local W = Instance.new("Weld")
				W.Part0 = g.Middle
				W.Part1 = C[i]
				local CJ = CFrame.new(g.Middle.Position)
				local C0 = g.Middle.CFrame:inverse()*CJ
				local C1 = C[i].CFrame:inverse()*CJ
				W.C0 = C0
				W.C1 = C1
				W.Parent = g.Middle
			end
				local Y = Instance.new("Weld")
				Y.Part0 = hit.Parent.UpperTorso
				Y.Part1 = g.Middle
				Y.C0 = CFrame.new(0, 0, 0)
				Y.Parent = Y.Part0
		end

		local h = g:GetChildren()
		for i = 1, # h do
			if h[i].className == "Part" or C[i].className == "UnionOperation" or C[i].className == "WedgePart" or C[i].className == "MeshPart" then
				h[i].Anchored = false
				h[i].CanCollide = false
			end
		end
		
	end
end

script.Parent.Touched:connect(onTouched)

Screenshot 2025-05-07 212308

2 Likes

Are you sure you are not welding the character to objects in the world?

I’ve tested it before, and when I step on the morph button, it shoves me into the morph and lags really badly, and I can’t move.

I think the reason why it is lagging is because the “touched” function is very sensitive, I would add a debounce feature to make it wait a bit for doing it again. I would also check if the player already has been morphed so the player can’t have morph multiple times.

How would I go about doing that? I’m not gonna lie, this isn’t my script, but I do know like the basics of coding

Nevermind, I did it, thank you so much!

1 Like

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