Hello can someone help me with this script my friend gave me? its a weld script, that when you touch the part it welds to your torso. But it only works when you touch it can someone help me do it when someone connects to the game? thanks.
I'm really new to lua and just needed that script to test out my gui i made.
script.Parent.Touched:connect(function(hit) humanoid = hit.Parent:findFirstChild("Humanoid") if humanoid then head = hit.Parent.Torso script.Parent.CFrame = head.CFrame * CFrame.new(-0.8,1,-0.0008) weld = Instance.new ("Weld") weld.Part0 = head weld.C0 = head.CFrame:inverse() weld.Part1 = script.Parent weld.C1 = script.Parent.CFrame:inverse() weld.Parent = script.Parent script.Parent.Anchored = false end end)
So basically it's pretty simple. Instead of:
script.Parent.Touched:connect(function(hit)
You would put:
game.Players.PlayerAdded:connect(function(player)
Then you would have to specify the parts of the player's character that you'd want to weld the parts to. So if you wanted the character's Head then you would do.
head = player.Character:FindFirstChild("Head") weld.Part0 = head weld.C0 = head.CFrame:inverse() weld.Part1 = script.Parent weld.C1 = script.Parent.CFrame:inverse()
Or if it were the Torso you wanted to weld to just change ("Head") to ("Torso"). Also if you're looking into working with R15, the "Torso" doesn't exist on an R15 character as a heads up. You should use "HumanoidRootPart" instead in that case.