Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

1 comment

0

the script is controlling all the server or only one player(the parent)?

1 answer

✓ Accepted answer
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

1 comment

0

You have to change the walk speed Aswell

This discussion is preserved as it was. New answers, comments, and votes are closed.