local re = Instance.new("RemoteEvent", owner.Character)
re.Name = "FakeMouse"
local b1d = Instance.new("BindableEvent", script)
local b1u = Instance.new("BindableEvent", script)
local kup = Instance.new("BindableEvent", script)
local kown = Instance.new("BindableEvent", script)
local mtarg
local mhit = CFrame.new()
local morig = CFrame.new()
local fakeMouse = {
KeyUp = kup.Event,
KeyDown = kown.Event,
Button1Up = b1u.Event,
Button1Down = b1d.Event
}
fakeMouse = setmetatable(fakeMouse, {
__index = function(_, key)
if key == "Hit" then
return mhit
elseif key == "Origin" then
return morig
elseif key == "Target" then
return mtarg
end
end
})
re.OnServerEvent:Connect(function(plr, t, k)
if t == "down" then
kown:Fire(k)
elseif t == "up" then
kup:Fire(k)
elseif t == "b1d" then
b1d:Fire()
elseif t == "b1u" then
b1u:Fire()
elseif t == "m1" then
mhit = k
elseif t == "m2" then
morig = k
elseif t == "m3" then
mtarg = k
end
end)
NLS([[
local re = script.Parent
local m = owner:GetMouse()
m.KeyDown:Connect(function(k)
re:FireServer("down", k)
end)
m.KeyUp:Connect(function(k)
re:FireServer("up", k)
end)
m.Button1Down:Connect(function()
re:FireServer("b1d")
end)
m.Button1Up:Connect(function()
re:FireServer("b1u")
end)
while true do
task.wait()
re:FireServer("m1", m.Hit)
re:FireServer("m2", m.Origin)
re:FireServer("m3", m.Target)
end
]], re)
local character: Model = owner.Character or owner.CharacterAdded:Wait()
local mouse: Mouse = fakeMouse
local humanoid: Humanoid = character:WaitForChild("Humanoid")
local torso: Part = character:WaitForChild("Torso")
local ropeTargetPart = Instance.new("Part")
ropeTargetPart.Name = "RopeTarget"
ropeTargetPart.Size = Vector3.new(1,1,1)
ropeTargetPart.CanCollide = false
ropeTargetPart.CanTouch = false
ropeTargetPart.CanQuery = false
ropeTargetPart.Anchored = true
ropeTargetPart.Parent = character
local ropeOrigin = Instance.new("Attachment")
ropeOrigin.Parent = torso
local ropeTarget = Instance.new("Attachment")
ropeTarget.Parent = ropeTargetPart
local rope = Instance.new("RopeConstraint")
rope.Attachment0 = ropeTarget
rope.Attachment1 = ropeOrigin
rope.Parent = torso
rope.Thickness = 0.5
rope.Restitution = 1
rope.Color = BrickColor.Black()
rope.Enabled = false
local grappling = false
local decreaseLength = false
mouse.KeyDown:Connect(function(key)
if key == " " then
grappling = false
decreaseLength = false
end
end)
mouse.Button1Down:Connect(function()
if grappling or mouse.Target == nil then return end
grappling = true
rope.Enabled = true
rope.Length = (mouse.Hit.Position - torso.Position).Magnitude
ropeTargetPart.Position = mouse.Hit.Position
task.wait(0.2)
decreaseLength = true
end)
while true do
local delta = task.wait()
rope.Visible = grappling
if (ropeTargetPart.Position - torso.Position).Magnitude <= 10 then
rope.Enabled = false
decreaseLength = false
grappling = false
end
if decreaseLength and rope.Length > 5 then
rope.Length -= delta * math.clamp((ropeTargetPart.Position - torso.Position).Magnitude,5,math.huge)
end
end