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

How would I freeze the player then weld it to a part?

Asked by
v_amp 6
5 years ago

This is for my elevator, i want it so it detects the player then welds them to the platform as it moves so the character isn't moving around then it will destroy the weld when the elevator stops. I've tried to do this in so many ways but i just can't detect the player for some reason..

0
the script is controlling all the server or only one player(the parent)? asdfghjk9019 225 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
local elevator = script.Parent

local weld =  Instance.new("WeldConstraint" ,elevator)
weld.Part0 = elevator

local range = 4 --if the player is less then 4 studs from the elevator it will weld

function weldToElevator(char)
    char.Humanoid.JumpPower = 0 --jump power is 0 so the player cant move at all
    weld.Part1 = char.PrimaryPart --weld the playet to the elevator
end

while wait() do
    for i,v in pairs(game.Players:GetChildren()) do --loop throw all the players
        if v.Character then
            if (v.Character.HumanoidRootPart.Position - elevator.Position).magnitude < range then --checks if the player is close to the elevator
                weldToElevator(v.Character)
            end
        end
    end
end
0
You have to change the walk speed Aswell 4n3w 0 — 5y
Ad

Answer this question