Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player = game.Players.LocalPlayer
- repeat wait() until Player.Character
- local Character = Player.Character
- local Humanoid = Character:WaitForChild("Humanoid")
- local SMG = Character:WaitForChild("SMG")
- local Flash = SMG:WaitForChild("Flash")
- local Mouse=Player:GetMouse()
- local Obj=nil
- local Prop=nil
- local IsAModel=nil
- local Grabbing=false
- local Primary=nil
- Mouse.KeyDown:connect(function(key)
- if key == "e" then
- local success, output = pcall(function()
- if not Grabbing then
- if Mouse.Target~=nil then
- local Target=Mouse.Target
- if Target:FindFirstChild("Prop") then
- Obj=Target
- Primary=Obj
- elseif Target.Parent:FindFirstChild("Prop") then
- Obj=Target.Parent
- if not Target:IsA("UnionOperation") then
- Primary=Obj.PrimaryPart
- else
- Primary=Target
- end
- end
- if Obj then
- if Obj.ClassName == "Model" then
- IsAModel = true
- else
- IsAModel = false
- end
- print("Is a model: "..tostring(IsAModel))
- Prop=Obj.Prop
- print(Primary.Name)
- local Distance=(Primary.Position-Flash.Position).magnitude
- if Distance <=15 then
- if not Prop.Value then
- Grabbing = true
- Prop.Value = true
- if IsAModel then
- for a,c in ipairs(Obj:children()) do
- local bp = Instance.new("BodyPosition",c)
- delay(0, function()
- while Grabbing do
- bp.position = (Flash.CFrame*CFrame.new(0,Distance,0)).p
- wait()
- end
- end)
- end
- else
- local bp = Instance.new("BodyPosition",Obj)
- while Grabbing do
- bp.position=(Flash.CFrame*CFrame.new(0,Distance,0)).p
- wait()
- end
- end
- end
- end
- end
- end
- else
- Grabbing=false
- Prop.Value=false
- if IsAModel then
- for a,c in ipairs(Obj:children()) do
- local bp = c:FindFirstChild("BodyPosition")
- if bp then
- bp:remove()
- end
- end
- else
- local bp = Obj:FindFirstChild("BodyPosition")
- if bp then
- bp:remove()
- end
- end
- Obj = nil
- Prop = nil
- IsAModel = nil
- end
- end)
- if not success then
- pcall(function()
- error(output)
- end)
- end
- end
- end)
- Humanoid.Died:connect(function()
- if Grabbing then
- Grabbing=false
- Prop.Value=false
- if IsAModel then
- for a,c in ipairs(Obj:children()) do
- local bp=c:FindFirstChild("BodyPosition")
- if bp then
- bp:remove()
- end
- end
- else
- local bp=Obj:FindFirstChild("BodyPosition")
- if bp then
- bp:remove()
- end
- end
- Obj=nil
- Prop=nil
- IsAModel=nil
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement