Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RStorage = game:GetService('ReplicatedStorage');
- local RService = game:GetService('RunService');
- local ObjectFunction = RStorage:WaitForChild('ObjectFunction');
- local UnequippedString = 'None';
- local WeldModel = require(script:WaitForChild('WeldModel'));
- local R6 = Enum.HumanoidRigType.R6;
- local R15 = Enum.HumanoidRigType.R15;
- local function GetObj(player)
- for i,v in pairs(workspace:GetDescendants()) do
- if (v:FindFirstChild('EquippedBy')) and (v.EquippedBy.Value == player.Name) then
- return v;
- end end
- return nil;
- end
- ObjectFunction.OnServerInvoke = function(player,Obj,Equipped,Hovering,Weld)
- if Weld ~= nil then
- Weld[1].C0 = Weld[2]
- return end;
- local Character = player.Character;
- local RigType = Character:WaitForChild('Humanoid').RigType;
- local Hand;
- if RigType == R6 then
- Hand = Character:WaitForChild('Right Arm');
- elseif RigType == R15 then
- Hand = Character:WaitForChild('RightHand');
- end
- if Equipped then
- local OldObj = GetObj(player)
- if OldObj:IsA('Model') then
- for i,v in pairs(OldObj:GetDescendants()) do
- if v:IsA('BasePart') then v.CanCollide = true;
- end end
- elseif OldObj:IsA('BasePart') then
- OldObj:FindFirstChildOfClass('Weld'):remove();
- OldObj.CanCollide = true;
- end
- OldObj.EquippedBy.Value = UnequippedString;
- end
- if Hovering then
- if (Obj.Parent:IsA('Model')) and (Obj.Parent:FindFirstChild('EquippedBy')) then
- local Model = Obj.Parent;
- local PrimaryPart = Model.PrimaryPart;
- if (not Model:FindFirstChild('EquippedBy')) then return{false,nil} end
- WeldModel.PerfectionWeld(Model);
- for i,v in pairs(Model:GetDescendants()) do if v:IsA('BasePart') then v.CanCollide = false end end;
- Model.EquippedBy.Value = player.Name;
- spawn(function()
- while (Model.EquippedBy.Value == player.Name) do
- RService.Heartbeat:wait();
- local lv = -Hand.CFrame.upVector;
- local size = PrimaryPart.Size.Y/2;
- Model:SetPrimaryPartCFrame(Hand.CFrame+Vector3.new(lv.X*size,lv.Y*size,lv.Z*size))
- end end)
- elseif Obj:IsA('BasePart') then
- if not Obj:FindFirstChild('EquippedBy') then return{Equipped} end;
- Obj.Anchored = false;
- local W = Instance.new('Weld',Obj);
- Obj.CanCollide = false;
- W.Part0 = Hand; W.Part1 = Obj;
- if RigType == R6 then
- W.C0 = CFrame.new(0,(-Obj.Size.Y/2)-.95,0)
- elseif RigType == R15 then
- W.C0 = CFrame.new(0,(-Obj.Size.Y/2)+.05,0)
- end
- Obj.EquippedBy.Value = player.Name;
- end
- end
- local EquipCheck = GetObj(player)
- if EquipCheck ~= nil then return{true,EquipCheck} else return{false,nil} end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement