Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a player stuck to a part?

Asked by 2 years ago

I am trying to make a tug of war round for my game, it is like from other squid game ones. I was able to add where when the player clicks a text button it moves, but now the problem is the player doesn't move with the part. I know people say "use weld" the thing is, I don't know how and if someone can give me a direct script for it that would be great. Thank you.

2 answers

Log in to vote
0
Answered by 2 years ago

I don't have a clear understanding on what your goal is here. But to get to your main question, on how you can make a player stuck to a part using a script it's pretty simple



local Players = game:GetService("Players") -- Getting the players service which isn't necessary but i intend to do so most of the time local player = Players.LocalPlayer -- Getting the player repeat wait() -- Repeating wait() and not allowing the code below this to execute until the player has loaded so the script won't cause any errors if let's say he left early until player.Character local char = player.Character local humRootPart = char:FindFirstChild("HumanoidRootPart") -- We're using the HumanoidRootPart as a position for the player since that's the part welded to majority of the bodyparts local part = nil -- Put the part you want the player to be stuck on here local function stickPlayerToPart() humRootPart.Anchored = true while wait() do -- We're putting this in a while loop so the player will countinuesly be stuck on that part no matter if that part changes position. This is optional depending if the part will change position. humRootPart.CFrame = part.CFrame -- Now we're applying the player's CFrame (HumanoidRootPart), to the part's CFrame end end stickPlayerToPart() -- Calling the function, you may want to call this function at different times, but i'm just showing you how you can acccomplish what you asked for

If you're not completely sure on what CFrame is as shown in the lua code, here's a better understandinng on what it is:

0
For some reason the link didn't show regarding to the CFrame ; https://developer.roblox.com/en-us/articles/Understanding-CFrame ZOOP1015 44 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

try

local Cd = 1 -- Cooldown stun duration
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.WalkSpeed = 0
hit.Parent.Humanoid.JumpPower = 0
        wait(Cd)-- Set to 99999999999999 if you want Stun to be infinite
hit.Parent.Humanoid.WalkSpeed = 16
hit.Parent.Humanoid.JumpPower = 50
end
end)

Answer this question