Player specific morph script

I’m trying to make a player specific morph script. I’ve already made the main morph script, but it’s currently an onTouched script, so it’s not player specific. What I want to be able to do is have the script check whenever a specific player (myself) joins the game or dies and then have it run the morph script and apply it to my character.

Below is a brief part of the morph script that gives me my helmet.

I’ve looked lots of places, but I can’t seem to find what I need, so any form of help would be greatly appreciated.

image

Script; Line → 4;
You trying add part in Humanoid
Replace g.Parent = hit.Parent on
g.Parent = hit.Parent.Parent

Syntax Error :
line 2; (‘findFirstChild’).
Syntax: FindFindChild:(“”)

Workspace
Char
BodyPart(hit variable)
Hit.Parent.Parent = workspace, Hit.Parent = the model of the character

Hmm
local s = hit.Parent:FindFirstChild(‘Humanoid’)
– s = Humanoid
s.Parent = Character

if the BodyPart’s parent(The characters) contains a humanoid, that means that’s a valid character. Not that the hit is a humanoid.

Oh okay okay im sorry me need learn lua ;/

script.Parent.Touched:Connect(onTouched)

You forgot call function

g.Parent = hit.Parent
hit == the body part that touched it inside the character
hit is inside the character, a child of it.
there fore hit’s Parent is the character, for further explanation

1 Like

onTouched is the function itself.
:Connect(function() works too, but you can make a function, call it the name, then just type connect(funcname) and it will pass over Hit to the function and run it,

Ohh I get what you mean. I think he just didn’t screenshot that part. @Wapple_Sterling next time, can you paste the code inside the post instead of screenshot?

Really? Then:

repeat
wait(0.1)
if game.Players.LocalPlayer.Character.Humanoid.Health <= 0 then
onTouched()
end
until 1 ~= 1

I get what you mean. I think he just didn’t screen shot that part

1 Like

But need answer on him question

in ServiceScript:

game.Players.PlayerAdded:Connection(function(plr)
if plr.Id == your id then
onTouched()
end
end)

This should help, try it out!

-- Keep onTouched only, then paste this under onTouched.
game:GetService("Players").PlayerAdded:Connect(function(plr)
      plr.CharacterAdded:Connect(function()
             repeat wait() until plr.Character:FindFirstChild("HumanoidRootPart")
             if plr.UserId == TheGuysUserId then
                     onTouched(plr.Character.HumanoidRootPart)
             end
      end
end

Like this?:

function onTouched(hit)
	game:GetService("Players").PlayerAdded:Connect(function(plr)
		plr.CharacterAdded:Connect(function()
			repeat wait() until plr.Character:FindFirstChild("HumanoidRootPart")
			if plr.UserId == 80207696 then
				onTouched(plr.Character.HumanoidRootPart)
			end
		end
	end
	if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Foot1") == nil then
		local g = script.Parent.Parent.Foot1:clone()
		g.Parent = hit.Parent
		local C = g:GetChildren()
		for i=1, #C do
			if C[i].className == "Part" or "Union" or "WedgePart" 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["LeftFoot"]
				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 "UnionOperation" or "WedgePart" then
				h[i].Anchored = false
				h[i].CanCollide = false
			end
		end
		
	end
end

script.Parent.Touched:connect(onTouched)

No, put the onTouched function first, then the plradded, like this

function onTouched(hit)

	if hit.Parent:findFirstChild("Humanoid")  and hit.Parent:findFirstChild("Foot1") = nil then
		local g = script.Parent.Parent.Foot1:clone()
		g.Parent = hit.Parent
		local C = g:GetChildren()
		for i=1, #C do
			if C[i].className == "Part" or "Union" or "WedgePart" 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["LeftFoot"]
				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 "UnionOperation" or "WedgePart" then
				h[i].Anchored = false
				h[i].CanCollide = false
			end
		end
		
	end
end
	game:GetService("Players").PlayerAdded:Connect(function(plr)
		plr.CharacterAdded:Connect(function()
			repeat wait() until plr.Character:FindFirstChild("HumanoidRootPart")
			if plr.UserId == 80207696 then
				onTouched(plr.Character.HumanoidRootPart)
			end
		end
	end




Doesn’t appear to work. I’ll keep testing stuff out, though.

The end function works fine, tested, I think onTouched has an error

Is this in a server script? Make sure its not local