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

Dragging dead players not working?

Asked by 2 years ago
Edited by JesseSong 2 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

So, I'm okay at scripting not the best. This is a re-post because my other anwsers just didn't work. Anyways here's the script I need help with.

local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid") 
local userInputService = game:GetService("UserInputService") 

local partA = playerModel.HumanoidRootPart 
local attachmentA = Instance.new("Attachment",partA)
local attachmentAPos = attachmentA.Position 
attachmentAPos = Vector3.new(0,0,-1)

local partB = script.Parent.RightHand 
local attachmentB = Instance.new("Attachment",partB) 
local attachmentBPos = attachmentB.Position
attachmentBPos = Vector3.new(0,0,-1)

humanoid(function(player) player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid").Died:Connect(function() if humanoid.Health >= 0 then local distance = (partA.Position - partB.Position).magnitude

                if distance == 10 then


    userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
    if input.UserInputType == Enum.UserInputType.Keyboard then if input.InputKeycode == Enum.KeyCode.E then local rodConstraint = Instance.new("RodConstraint",partA) rodConstraint .Attachment0 = attachmentA rodConstraint .Attachment1 = attachmentB


                   end
            end
           end)
        end
    end
end)
end) 
end)

It says Workspace.darkkitten12345.LocalScript:15: attempt to call a Instance value. I REALLY need help on this, thank you.

2 answers

Log in to vote
0
Answered by
appxritixn 2235 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

The error means you are attempting to treat an instance as a function. In this case, you are treating your humanoid as a function:

humanoid(function(player) player.CharacterAdded:Connect(function(character) 

The code which is giving the error in that line specifically is:

humanoid(function(player)

The opening bracket after the variable signifies to the code interpreter that you are attempting to call a function, and because an instance can't act as a function, the error is thrown.

I am not entirely sure what you are trying to do with the erroring code, but there is a list of events and methods that belong to the humanoid which can be found here.

If you have any further questions or errors, feel free to message me on Discord (phxntxsmic#2021)

0
Alright, thanks! I'll message you. darkkitten12345 8 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
local attachmentA = Instance.new("Attachment",partA) 
local attachmentAPos = attachmentA.Position
attachmentA.Parent = "insert parent here"

You forgot to parent the attachment somewhere, thats why its causing an error

0
The humanoid value on humanoid(function(player) player.CharacterAdded:Connect(function(character) keeps turning blue, that's where it's saying the valve is. I'm trying a lot of different ways anyway you can think of? darkkitten12345 8 — 2y
1
The error has nothing to do with where an Instance is/isn't parented. appxritixn 2235 — 2y
0
This answer is NOT correct! @Gmorcad12345 JesseSong 3916 — 2y

Answer this question