Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't the Touched Event activating?

I'm making a fireball script where you press Q to fire, but the damage part won't activate(Touched Event not activating).

local Player = script.Parent.Parent
local mouse = Player:GetMouse()

function Jutsu(key)
		if key:lower() == "q" then
			print("q activated")
-------------------------[Chakra Removal]--------------------------------
Player.Backpack.cpvalue.Value = Player.Backpack.cpvalue.Value - 5
			
			
-------------------------[Jutsu]-----------------------------------------
Flame = Instance.new("Part", Workspace)
Flame.CFrame = Player.Character.Torso.CFrame * CFrame.new(0,0,-5) * CFrame.Angles(33,0,0)
Flame.Shape = ("Ball")

MeshFlame = Instance.new("SpecialMesh", Flame)
MeshFlame.Scale = Vector3.new(2, 4, 2)
MeshFlame.MeshType = "FileMesh"
MeshFlame.MeshId = "http://www.roblox.com/asset/?id=25212400"			
MeshFlame.TextureId = "http://www.roblox.com/asset/?id=25212235"	

-------------------------[Velocity]--------------------------------------		
Movement = Instance.new("BodyVelocity", Flame)
Movement.maxForce = Vector3.new(math.huge, math.huge, math.huge)
Movement.velocity = Player.Character.Torso.CFrame.lookVector*40

------------------------[Effect]-----------------------------------------
function onTouched(Hit)
	print("Got Touched")
	if Hit.Parent:FindFirstChild("Humanoid") ~= nil then
		Hit.Parent.Humanoid.Health = Hit.Parent.Humanoid.Health - 20
	else
		Boom = Instance.new("Explosion", Flame)
		Boom.Position = Flame.Position
		
	end
end
Flame.Touched:connect(onTouched)	
-------------------------[Cooldown]--------------------------------------
			script.Disabled = true
			wait(20)
			script.Disabled = false
				
			
			
		end
	
	end
	
	mouse.KeyDown:connect(Jutsu)

3 comments

0

Are you getting any output at all?

0

Nope.

2

I don't think that it is possible to have connection lines inside of functions. Also, your onTouched function probably shouldn't be inside of the other one. Try moving the onTouched function and its connection line outside of the Jutsu function.

1 answer

Maybe for some reason it thinks Flame doesn't exist? Try putting if Flame then on line 13, since everything has to do with Flame.

7 comments

0

No, doesn't work :( Thanks though

0

How about line 28 is flame.Touched:connect(function(Hit), and line 37 is end). Maybe that does something?

0

No but we get in the output: Attempt to connect failed: Passed value is not a function

0

Slick is right. If you have the Touched event firing inside another event, the Touched event will only fire once the function it's inside of fires. So, onTouched will only fire whenever Jutsu does.

0

But, it won't recognize the Flame if its outside the function... Should I rewrite the entire script?

0

I recommend putting another script inside of the flame to handle the touched event, similarly to how most older guns worked, which were all based on the linked paintball gun. One script for shooting, another for the projectile.

0

Thanks I'll try that.

This discussion is preserved as it was. New answers, comments, and votes are closed.