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)
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.
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