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.
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
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?
-- 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
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