How can i make this part be inside a player once they touch it, they inherit the part

This is inside a part shaped like a arm in workspace, once i touch it i inherit the things below, how can i make it so it becomes my left and right arm, like a zombie once i touch it.

function morph(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
 local player = hit.Parent:FindFirstChild("Humanoid").Parent
 local bodycolors = player:FindFirstChild('Body Colors')

--changes body color
bodycolors.HeadColor = BrickColor.new('Artichoke')
bodycolors.RightArmColor = BrickColor.new('Artichoke')
bodycolors.LeftArmColor = BrickColor.new('Artichoke')
bodycolors.LeftLegColor = BrickColor.new('Artichoke')
bodycolors.RightLegColor = BrickColor.new( 'Artichoke')
bodycolors.TorsoColor = BrickColor.new('Artichoke')

--changes face
player.Head.face.Texture = 'http://www.roblox.com/asset/?id=174393211'

--changes animation
local animate = script.Parent.Animate:Clone()
player.Animate:Destroy()
animate.Parent = player
animate.Disabled = false

	end
	
	--removes accessories
local d = hit.Parent:GetChildren() 
	for i=1, #d do 
		if (d[i].className == "Accessory") then 
			d[i]:remove()
		end
	end
	
end

script.Parent.Touched:connect(morph)
2 Likes

Animation Switch Alternative


How about using Motor6D.Transform methods that overrides the default animations instead?

There is an announcement about the feature below here:

Lines Samples – No need to destroy the old animation script.

character.LeftUpperArm.LeftShoulder.Transform = character.LeftUpperArm.LeftShoulder.Transform * CFrame.Angles(math.rad(90), 0, 0)
character.RightUpperArm.RightShoulder.Transform = character.RightUpperArm.RightShoulder.Transform * CFrame.Angles(math.rad(90), 0, 0)
1 Like

Like this?
it casues an error idk if i put it right
[Workspace.Smooth Block Model.Script:26: attempt to index local ‘player’ (a nil value)]

 function morph(hit)
    	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
     local player = hit.Parent:FindFirstChild("Humanoid").Parent
     local bodycolors = player:FindFirstChild('Body Colors')

--changes body color
bodycolors.HeadColor = BrickColor.new('Artichoke')
bodycolors.RightArmColor = BrickColor.new('Artichoke')
bodycolors.LeftArmColor = BrickColor.new('Artichoke')
bodycolors.LeftLegColor = BrickColor.new('Artichoke')
bodycolors.RightLegColor = BrickColor.new( 'Artichoke')
bodycolors.TorsoColor = BrickColor.new('Artichoke')

--changes face
player.Head.face.Texture = 'http://www.roblox.com/asset/?id=174393211'

--changes animation
local animate = script.Parent.Animate:Clone()
player.Animate:Destroy()
animate.Parent = player
animate.Disabled = false

end

local player = game.Players.LocalPlayer
local character = player.Character

character.LeftUpperArm.LeftShoulder.Transform = character.LeftUpperArm.LeftShoulder.Transform * CFrame.Angles(math.rad(90), 0, 0)
character.RightUpperArm.RightShoulder.Transform = character.RightUpperArm.RightShoulder.Transform * CFrame.Angles(math.rad(90), 0, 0)
--removes accessories
local d = hit.Parent:GetChildren() 
	for i=1, #d do 
		if (d[i].className == "Accessory") then 
			d[i]:remove()
		end
	end
	
end

script.Parent.Touched:connect(morph)

Warning though, servers don’t have any LocalPlayer indexed. That’s why you have to use:

local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) -- which in most cases of .Touched event

Also are you speaking about arm meshes or something else?