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

Why doesn't the Touched Event activating?

Asked by 9 years ago

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)
0
Are you getting any output at all? adark 5487 — 9y
0
Nope. zipper01 62 — 9y
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. SlickPwner 534 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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.

0
No, doesn't work :( Thanks though zipper01 62 — 9y
0
How about line 28 is flame.Touched:connect(function(Hit), and line 37 is end). Maybe that does something? bobafett3544 198 — 9y
0
No but we get in the output: Attempt to connect failed: Passed value is not a function zipper01 62 — 9y
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. bobafett3544 198 — 9y
View all comments (3 more)
0
But, it won't recognize the Flame if its outside the function... Should I rewrite the entire script? zipper01 62 — 9y
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. Defaultio 160 — 9y
0
Thanks I'll try that. zipper01 62 — 9y
Ad

Answer this question