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

How do I clone a block onto a player's head?

Zarm does not work for r15, I tried making it so instead of removing player's arms,the zarm clones itself onto a player's head without removing it but it does not work,pls help

Script starts here:

wait(1) owner=script.Parent.Parent.Name

function onTouched(part) if part.Parent = nil then local h = part.Parent:findFirstChild("Humanoid") if h=nil then if cantouch~=0 then if h.Parent.Name~=owner then

					if h.Parent:findFirstChild("zarm")~=nil then return end

					cantouch=0

					local head=h.Parent:findFirstChild("Head")
					
					

					local zee=script.Parent.Parent:findFirstChild("zarm")
					if zee~=nil then
						local zarm=zee:clone()
						if zarm~=nil then

						local rot=CFrame.new(0, 0, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
							zarm.CFrame=h.Parent.Torso.CFrame * CFrame.new(Vector3.new(-1.5,0.5,-0.5)) * rot
							zarm.CFrame=h.Parent.Torso.CFrame * CFrame.new(Vector3.new(1.5,0.5,-0.5)) * rot
							zarm.Parent=h.Parent
							zarm.Parent=h.Parent
							zarm:makeJoints()
							zarm:makeJoints()
							zarm.Anchored=false
							zarm.Anchored=false
							wait(0.1)
							h.Parent.Head.Color=zee.Color
						else print("no zee"); return end
					end
					wait(1)
					cantouch=1
				end
			end
		end
end

end

script.Parent.Touched:connect(onTouched)

1 answer

I will give you the basics of attaching a part to a player's head.

local bluepart = script.Parent

function onTouch (hit)
	local head = hit.Parent.Head
	bluepart.CFrame = head.CFrame* CFrame.new(0,10,0)
	local weld = Instance.new("Weld")
	weld.Part0 = head
	weld.Part1= bluepart
	weld.Parent = bluepart
end)

bluepart.Touched:Connect(onTouch)

make sure part is unachored and cancollide is false.

if you encounter this problem -- "the part teleports the player and sometimes welds under the player" add

weld.C0 = head.CFrame:Inverse()
weld.C1 = bluepart.CFrame:Inverse()

so you have

local bluepart = script.Parent

function onTouch (hit)
	local head = hit.Parent.Head
	bluepart.CFrame = head.CFrame* CFrame.new(0,10,0)
	local weld = Instance.new("Weld")
	weld.Part0 = head
	weld.Part1= bluepart
	weld.C0 = head.CFrame:Inverse()
	weld.C1 = bluepart.CFrame:Inverse()
	weld.Parent = bluepart
end)

bluepart.Touched:Connect(onTouch)

1 comment

0

Without collisions the part falls through the ground,found a way to fix that but when I touch the part (go through it) nothing happens.

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