Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Dragging dead players not working?

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

✓ Accepted answer

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)

1 comment

0

Alright, thanks! I'll message you.

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

3 comments

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?

1

The error has nothing to do with where an Instance is/isn't parented.

0

This answer is NOT correct! @Gmorcad12345

This discussion is preserved as it was. New answers, comments, and votes are closed.