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

Fire Ball Script Not Damage Humanoid?

Asked by 8 years ago
Edited 8 years ago

So what this script does is, create the part, increase it's size then launch it, that happens, and damage any humanoids it touches, but it does not damage humanoids i made some dummy npc's and they take no damage ;-;(local script btw)

01function onKeyDown(key)
02    local Key = key:lower()
03    if key == "f" then
04 
05--      local animationTrack = Humanoid:LoadAnimation(MagicAnim) -- This is here because i have not made an anim for this yet, but i doubt that matters ;-;
06--      animationTrack:Play()
07        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
08        sound:Play()
09        local Ball = Instance.new('Part')
10        Ball.Shape = 'Ball'
11        Ball.Size = Vector3.new(2,2,2)
12        Ball.Material = 'Neon'
13        Ball.BrickColor = BrickColor.new('Really red')
14        Ball.Name = 'FireBallOf'..Player.Name
15        Ball.Parent = game.Workspace
View all 59 lines...

1 answer

Log in to vote
2
Answered by 8 years ago
Edited 8 years ago

Your code

Friaza's tutorial is very useful to get someone use to KeyDown() functions, and the code you have is ALMOST perfect, however, some parts of your code aren't exactly perfect. For the code to work, you need two scripts: a local script and a regular script. Name the local script 'Fireball' and name the script 'Firedamage' (Have Firedamage INSIDE Fireball, and have the code be a child of StarterPack). Now, in the Firedamage code, put this edited code into it (I'll explain the code to the best of my ability...)

Firedamage Code

01function onDamage(Part)--function to cause damage to those hit with fireball
02 
03    if Part.Parent:FindFirstChild("Humanoid") ~=nil and Part.Parent.Name ~= "script.Parent.Name" then--If the thing is humanoid then
04 
05        script.Disabled = true
06 
07        local f = Instance.new('Fire', Part)
08 
09        for i = 1,25 do--Does damage all the way to 25
10 
11            f.Size = f.Size +0.25--
12 
13            Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -1--Declines health -1
14 
15        wait (0.05)
View all 29 lines...

Now, in the Fireball code, you need to put this edited code into it (again, I'll explain to the best of my ability...)

Fireball code

01--Variables
02Player = script.Parent.Parent--To get to Player
03 
04mouse = Player:GetMouse()--Gets the mouse function
05 
06--function
07 
08function onKeyDown(key)--The function
09 
10    local Key = key:lower()--Key pressed sequence
11 
12    if key =='z' then--The player hits 'z'
13 
14        local x = Instance.new('Part', workspace)--Creates a new part
15 
View all 60 lines...

In conclusion...

Your code was right, but I have some edits to it to have it cleaner. Let me know if it doesn't work.

Greek

2
It worked perfect! :) TestingPlace1337 51 — 8y
0
Thanks for letting me know :) GreekGodOfMLG 244 — 8y
Ad

Answer this question