Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Trying to make a drag dead people script but it keeps giving me an error?

Asked by 4 years ago
Edited 4 years ago

So, lets go into the thing.

I decided to make a drag dead people tool which has the ragdoll death script with it however whenever I click on the player to drag them I get this message:

Dragger (The ServerSript), Line 5: invalid argument #2 (string expected, got Instance)

I am using an event and using a rope to drag for this so here are the scripts:

The LocalScript ("Get")

function getMouseTarget()
    local cursorPosition = game:GetService("UserInputService"):GetMouseLocation()
    local oray = game.workspace.CurrentCamera:ViewportPointToRay(cursorPosition.x, cursorPosition.y, 0)
    local ray = Ray.new(game.Workspace.CurrentCamera.CFrame.p,(oray.Direction * 1000))
    return workspace:FindPartOnRay(ray)
end

script.Parent.Activated:Connect(function(mouse)
local part, mousepos = getMouseTarget()
    if part.Parent.Humanoid.Health <= 0 then
        local plrClick = part.Parent
        script.Parent.DragPlr:FireServer(game.Players.LocalPlayer.Character, plrClick.Name)
    end
end)

The ServerScript ("Dragger")

script.Parent.OnServerEvent:Connect(function(plr1, plr2)
    local rope = Instance.new("RopeConstraint", workspace)
    local at0 = workspace[plr2].Torso:FindFirstChild("Attachment")
    local at1 = plr1.Torso:WaitForChild("BodyFrontAttachment")
    rope.Attachment0 = at0
    rope.Attachment1 = at1
end)

Why does it give me the error?

Answer this question