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