I'm trying to make a exploding barrel for my game but for it in order to explode it needs to be click but it doesn't work when i try it.Any help?
Script:
script.Parent.mouseClick:connect(function() local explosionPart = script.Parent local explosion = Instance.new("Explosion" , game.Workspace) explosion.Position = explosionPart.Position explosionPart:Destroy() end)
The problem is that there's no such event as "mouseClick". Keep in mind that in lua everything is case sensitive. Also you should add a "ClickDetector" into the part, because parts don't have the event "MouseClick" which is needed in this case. Here's what your script should look like.
local ClickDetector = Instance.new("ClickDetector", script.Parent) ClickDetector.MouseClick:connect(function(playerWhoClicked) local explosionPart = script.Parent local explosion = Instance.new("Explosion" , game.Workspace) explosion.Position = explosionPart.Position explosionPart:Destroy() end)
Parts don't have a mouseclick. You have to put a clickdetector inside of the part first and the change script.Parent.mouseClick to script.Parent.ClickDetector.MouseClick