Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Services
- local get = function(x) return game:GetService(x) end
- local players = get('Players')
- local ws = get('Workspace')
- local rs = get('ReplicatedStorage')
- local rus = get('RunService')
- local uis = get('UserInputService')
- local coregui = get('CoreGui')
- local http = get('HttpService')
- local ts = get('TeleportService')
- -- Shorthand
- local plr = players.LocalPlayer
- local char = (plr and (plr.Character or plr.CharacterAdded:Wait()) or nil)
- local hrp = plr and (char:WaitForChild('HumanoidRootPart')) or nil
- local hum = plr and (char:WaitForChild('Humanoid')) or nil if plr then plr.CharacterAdded:Connect(function(c)char=c hrp=c:WaitForChild'HumanoidRootPart'hum=c:WaitForChild('Humanoid')end)end
- local cf = CFrame
- local v3 = Vector3
- local ud2 = UDim2
- local c3 = Color3
- local rgb = c3.fromRGB
- local step = rus.Stepped
- local rstep = rus.RenderStepped
- local heartbeat = rus.Heartbeat
- -- Functions
- local function bindToStep(callback,doDebounce,debounceWait)
- local debounce = false
- step:Connect(function()
- if not debounce then
- debounce = doDebounce ~= nil
- callback()
- if debounceWait and doDebounce then
- wait(debounceWait)
- end
- debounce = false
- end
- end)
- end
- local function bindToRenderStep(callback,doDebounce,debounceWait)
- local debounce = false
- rstep:Connect(function()
- if not debounce then
- debounce = doDebounce ~= nil
- callback()
- if debounceWait and doDebounce then
- wait(debounceWait)
- end
- debounce = false
- end
- end)
- end
- local function bindToHeartbeat(callback,doDebounce,debounceWait)
- local debounce = false
- heartbeat:Connect(function()
- if not debounce then
- debounce = doDebounce ~= nil
- callback()
- if debounceWait and doDebounce then
- wait(debounceWait)
- end
- debounce = false
- end
- end)
- end
- local JSON = {
- stringify = function(...) return http:JSONEncode(...) end;
- parse = function(...) return http:JSONDecode(...) end;
- }
- ------------------------------------------------------------------------------------------------------------------
- -- Module --
- local module = {}
- -- Configure Constraints --
- function module.configureAlignment(part0,part1,useBodyPosition) -- configures the two parts so that they are ready to be aligned. After this is done, you can set the position and orientation of the "part1_attAP" attachment, which is the attachment inside of part1
- local function create(c,part0)
- local obj = Instance.new(c)
- for i,v in pairs(part0) do
- obj[i] = v
- end
- return obj
- end
- local part0_attP = create('Attachment',{
- Parent = part0;
- })
- local part1_attP = create('Attachment',{
- Parent = part1;
- })
- local part0_attO = create('Attachment',{
- Parent = part0;
- })
- local part1_attO = create('Attachment',{
- Parent = part1;
- })
- local ap = create('AlignPosition',{
- Name = 'LFbodyf';
- Parent = part0;
- ApplyAtCenterOfMass = true;
- MaxForce = 67752;
- MaxVelocity = math.huge/9e110;
- ReactionForceEnabled = false;
- Responsiveness = 200;
- RigidityEnabled = false;
- Attachment0 = part0_attP;
- Attachment1 = part1_attP;
- })
- local ao = create('AlignOrientation',{
- Name = 'LFbodyf';
- Parent = part0;
- MaxAngularVelocity = math.huge/9e110;
- MaxTorque = 67752;
- PrimaryAxisOnly = false;
- ReactionTorqueEnabled = false;
- Responsiveness = 200;
- RigidityEnabled = false;
- Attachment0 = part0_attO;
- Attachment1 = part1_attO;
- })
- --[[ delay(1,function()
- ap.RigidityEnabled = true
- ao.RigidityEnabled = true
- end) ]]
- local data = {
- info = {
- alignPos = ap;
- alignOri = ao;
- attachments = {
- part0 = {
- pos = part0_attP;
- ori = part0_attO;
- };
- part1 = {
- pos = part1_attP;
- ori = part1_attO;
- };
- }
- };
- }
- function data.setpos(pos)
- part1_attP.Position = pos
- end
- function data.setori(ori)
- part1_attO.Orientation = ori
- end
- if useBodyPosition then
- local bp = Instance.new('BodyPosition',part0)
- bp.Name = 'FFmover'
- --[[ bp.MaxForce = v3.new(9e9,9e9,9e9)
- bp.P = 100
- bp.D = 100 ]]
- bindToStep(function()
- if bp then
- bp.Position = part1_attP.Position
- end
- end)
- end
- return data
- end
- -- Return the module --
- return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement