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

Passed value is not a function but still doesn't work?

Asked by 5 years ago

I have been reading many articles, and I have no idea what happened to my script.

I know what is "Passed value is not a function"

It means you cannot call a function that hasn't been defined yet.

I tried to solve, but it still acts the same.

This is my code:

local Char = script.Parent
repeat wait() until Char:FindFirstChildWhichIsA("Humanoid")
function OnDeathR15()
local Vars = Char:GetDescendants()
for index,var in pairs(Vars) do
    if var.ClassName == "Motor6D" then
        local Part0 = var.Part0
        local Part1 = var.Part1
        local Constraint = Instance.new("BallSocketConstraint")
        Constraint.Parent = Char
        --Set fake joint(But realistic!)
        Constraint.LimitsEnabled = true
        Constraint.TwistLimitsEnabled = true
        Constraint.UpperAngle = 45
        Constraint.TwistLowerAngle = -45
        Constraint.TwistUpperAngle = 45
        --Set Attachments
        local Attach0 = Instance.new("Attachment")
        local Attach1 = Instance.new("Attachment")
        Attach0.Name = "Attach0"
        Attach1.Name = "Attach1"
        Attach0.Parent = Part0
        Attach1.Parent = Part1
        --Weld two part to a JOINT
        Constraint.Attachment0 = Attach0
        Constraint.Attachment1 = Attach1
    end
end
end
Char:FindFirstChildWhichIsA("Humanoid").Died:Connect(OnDeathR15()) -- I think this is the error.

Sincerely, DERP9487.

1 answer

Log in to vote
1
Answered by
OnaKat 444 Moderation Voter
5 years ago

Use OnDeathR15 without ()

Char:FindFirstChildWhichIsA("Humanoid").Died:Connect(OnDeathR15)
0
Thanks, but could you tell me why? DERP9487 41 — 5y
0
@DERP9487 When you make function you will need () but when you use :Connect() you don't need it. OnaKat 444 — 5y
Ad

Answer this question