Make a player stick to a part!

I was experimenting in the studio and I was wondering:
How to make a player “anchor” with the part?
In other words, the player is glued to the part.
Currently I have only done this, I think it should serve what I want to achieve:

game.Workspace.Part1.Touched:Connect(function(Object)
if Object.Parent:FindFirstChild(“Humanoid”) then
print(“Character Detected”)
end
end)

2 Likes

you would want to weld the player to the part rather than anchor them

This could be done fairly simply using

local new = instance.new('Weld')
2 Likes

But I wonder how to achieve it?

There are a couple resources you could use to achieve this and learn how welds work. I’d recommend looking into this link first: Welds Wiki Then you could also watch a video too if that will help the learning process. Here is a good one for welds: Weld video

1 Like

You can then edit it like so to set the weld like so:

new.Part1 = workspace.Part
Part2 = Player.Character.HumanoidRootPart
new.Parent = workspace.Part

This would set the weld so it welds the character to the selected part

1 Like

Could you be more specific please?

I thought it was pretty specific, if you want a glue-type functionality, use the code @topdog_alpha wrote for you and make sure the part that the player is being welded too is anchored. This will prevent the player from moving from the brick AKA glue-type effect. Also take a look at the resources I posted. The ROBLOX Wiki is pretty helpful. One last thing to note, When you want the player to be unglued, make sure to destroy the weld using

new:Destroy()

Then every time the touched event runs again, if you used the code provided it will make a new instance of the weld and weld the player to the brick.