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

attempt to index global 'death' (a function value)?

Asked by 7 years ago

I'm trying to make a nuke that calls :BreakJoints() on humanoids in game. I keep getting this error though not sure what I'm doing wrong.

13:20:57.457 - Workspace.Brick.Script:23: attempt to index global 'death' (a function value) 13:20:57.457 - Stack Begin 13:20:57.458 - Script 'Workspace.Brick.Script', Line 23 13:20:57.458 - Stack End

function Cough(Part)
local fries = Instance.new('Message')
fries.Parent = game.Workspace
fries.Text = "Hello I will now explode"
wait(3)
fries:Destroy()
local explosion = Instance.new('Part', game.Workspace)
Part = explosion
Part.Anchored = true
Part.Shape = 'Ball'
Part.Transparency = 0.1
Part.TopSurface = "Smooth"
Part.BottomSurface = "Smooth"
Part.CanCollide = false
while true do
Part.Size = Part.Size + Vector3.new(10,10,10)
wait()
end

end
hum = game.Workspace:FindFirstChild("Humanoid")
function death(hum)
    if death.Touched:FindFirstChild(hum)then
        hum:BreakJoints()
        end
end

script.Parent.Touched:connect(Cough)
game.Workspace.Brick.Touched:connect(death)
wait(10)



2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

A function cannot be touched. Instead, a 3D part can be. Also, .Touched is not a property. I am going to rewrite the stuff.

function Cough(Part)
local fries = Instance.new('Message')
fries.Parent = game.Workspace
fries.Text = "Hello I will now explode"
wait(3)
fries:Destroy()
local explosion = Instance.new('Part', game.Workspace)
Part = explosion
Part.Anchored = true
Part.Shape = 'Ball'
Part.Transparency = 0.1
Part.TopSurface = "Smooth"
Part.BottomSurface = "Smooth"
Part.CanCollide = false
while true do
Part.Size = Part.Size + Vector3.new(10,10,10)
wait()
end

end
local deb = false
hum = game.Workspace:FindFirstChild("Humanoid")
function death(hum)
    if hum:FindFirstChild('Humanoid') and deb == false then --I'm assuming you are checking for a humanoid. I'm confused as what you wanted here.
    deb = true
        hum:BreakJoints()
    wait(1)
    deb = false
        end
end

script.Parent.Touched:connect(Cough)
game.Workspace.Brick.Touched:connect(death)
wait(10) --A wait here does nothing, as there is no code after the wait.
0
I am trying to do a check for if the part was touched by a humanoid. And if you can I cant figure out how to make the function happen once instead of happening thousands of times when you step on the brick. SacredEden 10 — 7y
0
Ohh ok hiimgoodpack 2009 — 7y
0
well do you know how i can fix it? xd SacredEden 10 — 7y
0
I DID I JUST MADE AN EDIT Ok? hiimgoodpack 2009 — 7y
View all comments (3 more)
0
bud i asked becuase you didn't fix it, OK? SacredEden 10 — 7y
0
DID YOU EVEN COPY THE NEW SCRIPT? hiimgoodpack 2009 — 7y
0
Yeah I did it still doesn't work for me. PLUS I already made a different version and that still doesn't work SacredEden 10 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

the "hum" at line 21 is useless, remove it. the touched event returns the part that touched it. so to check if a player has touched it, and has a humanoid then remove the death function and put this instead:

death = function(part)
    if part.Parent:FindFirstChild"Humanoid" then
        part.Parent.Humanoid:BreakJoints()
    end
end

Answer this question