-- Grapple People Simulator Script

-- The local player (the one executing the script)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

-- Variables for the grapple system
local grappleHook = Instance.new("Part")  -- This is the grapple hook
grappleHook.Size = Vector3.new(1, 1, 1)
grappleHook.Shape = Enum.PartType.Ball
grappleHook.Anchored = false
grappleHook.CanCollide = false
grappleHook.Material = Enum.Material.SmoothPlastic
grappleHook.BrickColor = BrickColor.new("Bright red")
grappleHook.Parent = game.Workspace

local grappleDistance = 50  -- The maximum distance the grapple can reach
local pullingSpeed = 50  -- Speed of pulling towards the grapple
local pulling = false  -- If the player is currently being pulled by the grapple

-- Function to fire the grapple hook
function fireGrapple()
    -- Get the position of the mouse
    local targetPosition = mouse.Hit.p
    
    -- Set the grapple hook's position to the player's current position
    grappleHook.Position = player.Character.HumanoidRootPart.Position

    -- Create a rope between the player and the target (using a BodyPosition)
    local rope = Instance.new("RodConstraint")
    rope.Attachment0 = grappleHook:CreateAttachment()
    rope.Attachment1 = player.Character.HumanoidRootPart:CreateAttachment()
    rope.Parent = game.Workspace
    
    -- Move the grapple hook towards the target
    local direction = (targetPosition - grappleHook.Position).unit
    local distance = (targetPosition - grappleHook.Position).magnitude
    
    while distance > 1 do
        -- Move the grapple hook in the direction of the target
        grappleHook.Position = grappleHook.Position + direction * 2
        
        -- Recalculate distance to the target
        distance = (targetPosition - grappleHook.Position).magnitude
        wait(0.1)
    end

    -- If we have reached the target, start pulling
    if not pulling then
        pulling = true
        -- Pull the player towards the grapple point
        while pulling do
            player.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame:Lerp(grappleHook.CFrame, pullingSpeed * 0.05)
            wait(0.1)
        end
    end
end

-- Listen for when the player clicks to fire the grapple
mouse.Button1Down:Connect(function()
    fireGrapple()
end)

-- Clean up when the player disconnects
player.OnLeaving:Connect(function()
    if grappleHook then
        grappleHook:Destroy()
    end
end)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: