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
01 | function Cough(Part) |
02 | local fries = Instance.new( 'Message' ) |
03 | fries.Parent = game.Workspace |
04 | fries.Text = "Hello I will now explode" |
05 | wait( 3 ) |
06 | fries:Destroy() |
07 | local explosion = Instance.new( 'Part' , game.Workspace) |
08 | Part = explosion |
09 | Part.Anchored = true |
10 | Part.Shape = 'Ball' |
11 | Part.Transparency = 0.1 |
12 | Part.TopSurface = "Smooth" |
13 | Part.BottomSurface = "Smooth" |
14 | Part.CanCollide = false |
15 | while true do |
A function cannot be touched. Instead, a 3D part can be. Also, .Touched is not a property. I am going to rewrite the stuff.
01 | function Cough(Part) |
02 | local fries = Instance.new( 'Message' ) |
03 | fries.Parent = game.Workspace |
04 | fries.Text = "Hello I will now explode" |
05 | wait( 3 ) |
06 | fries:Destroy() |
07 | local explosion = Instance.new( 'Part' , game.Workspace) |
08 | Part = explosion |
09 | Part.Anchored = true |
10 | Part.Shape = 'Ball' |
11 | Part.Transparency = 0.1 |
12 | Part.TopSurface = "Smooth" |
13 | Part.BottomSurface = "Smooth" |
14 | Part.CanCollide = false |
15 | while true do |
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:
1 | death = function (part) |
2 | if part.Parent:FindFirstChild "Humanoid" then |
3 | part.Parent.Humanoid:BreakJoints() |
4 | end |
5 | end |