Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local grappling = false
- local createdInstances
- local oldHipHeight
- local oldVel
- local function SetHipHeight(num)
- local hum = plr.Character.Humanoid
- oldHipHeight = hum.HipHeight
- hum.HipHeight = num
- end
- local function Stop()
- grappling = false
- rs.RemoteEvent:FireServer("GrappleFinished")
- table.foreach(createdInstances,function(_,v) v:Destroy() end)
- SetHipHeight(oldHipHeight)
- plr.Character.PrimaryPart.Velocity = Vector3.new(0,0,0)
- end
- local function CreateInstances(att1,pos)
- local att0 = Instance.new("Attachment")
- local ball = script.Ball:Clone()
- ball.Position = pos
- local ap = script.AlignPosition:Clone()
- ap.Attachment0 = att0
- ap.Attachment1 = att1
- ball.Parent = plr.Character
- att0.Parent = plr.Character.PrimaryPart
- ap.Parent = plr.Character
- createdInstances = {att0, ap, ball = ball}
- end
- local function CheckIfStuck(newVel)
- if newVel:isClose(oldVel,0.001) then
- Stop()
- return
- end
- self.oldVel = newVel
- end
- game:GetService("UserInputService").InputBegan:Connect(function(i,g)
- if i.KeyCode == Enum.KeyCode.F and not g then
- local mouseh = mouse.Hit
- local att1, p = rs.RemoteFunction:InvokeServer("Grappled",mouseh)
- if att1 and p then
- grappling = true
- SetHipHeight(0)
- CreateInstances(att1,p)
- createdInstances.ball.Touched:Connect(function(h)
- if game.Players:GetPlayerFromCharacter(h.Parent) == plr then
- Stop()
- end
- end)
- oldVel = plr.Character.PrimaryPart.Velocity
- while grappling and game:GetService("RunService").Heartbeat:Wait() do
- grapple:CheckIfStuck(plr.Character.PrimaryPart.Velocity)
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement