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)
function onKeyDown(key) local Key = key:lower() if key == "f" then -- local animationTrack = Humanoid:LoadAnimation(MagicAnim) -- This is here because i have not made an anim for this yet, but i doubt that matters ;-; -- animationTrack:Play() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0 sound:Play() local Ball = Instance.new('Part') Ball.Shape = 'Ball' Ball.Size = Vector3.new(2,2,2) Ball.Material = 'Neon' Ball.BrickColor = BrickColor.new('Really red') Ball.Name = 'FireBallOf'..Player.Name Ball.Parent = game.Workspace Ball.CFrame = game.Players.LocalPlayer.Character.Torso.CFrame * CFrame.new(0,0,-2) Ball.CanCollide = false Ball.Anchored = true local start = Ball.Size local finish = Ball.Size * Vector3.new(5,5,5) local FireParticle = Instance.new('ParticleEmitter',Ball) FireParticle.Texture = 'http://www.roblox.com/asset/?id=300899516' local Part = Ball -- this is the Part we will move local newPos = (game.Players.LocalPlayer.Character.Torso.CFrame * CFrame.new(0,0,-550)).p -- the position the Part will go to local Time = 2 -- the time that the script will take to move the part local Increment = 5 -- the Part will move 0.5 studs each time it moves local balldebounce = false local Diff = newPos - Part.Position -- the difference between the two positions local Mag = Diff.magnitude -- the distance between the two parts local Direction = CFrame.new(Part.Position, newPos).lookVector for progress = 0, 1, 0.03 do Ball.Size = start:lerp(finish, progress) wait() end Ball.Touched:connect(function(part) if Part.Parent ~= nil then--Keep Parentless blocks from breaking it. if balldebounce == false and Part.Parent:findFirstChild("Humanoid") ~= nil then balldebounce = true Part.Parent:findFirstChild("Humanoid"):TakeDamage(40) wait(1)--Wait two seconds before the brick can hurt someone. balldebounce = false end end end) for n = 0, Mag, Increment do Part.CFrame = Part.CFrame + (Direction * Increment) wait() end game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 end end mouse.KeyDown:connect(onKeyDown)
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
function onDamage(Part)--function to cause damage to those hit with fireball if Part.Parent:FindFirstChild("Humanoid") ~=nil and Part.Parent.Name ~= "script.Parent.Name" then--If the thing is humanoid then script.Disabled = true local f = Instance.new('Fire', Part) for i = 1,25 do--Does damage all the way to 25 f.Size = f.Size +0.25-- Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -1--Declines health -1 wait (0.05) end--end the first argument of code chunk f:remove() Part.Parent.Humanoid.PlatformStand = true script.Parent:remove()--Removes the action end--end the second argument of code chunk end--end the thrid argument of code chunk script.Parent.Touched:connect(onDamage)
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
--Variables Player = script.Parent.Parent--To get to Player mouse = Player:GetMouse()--Gets the mouse function --function function onKeyDown(key)--The function local Key = key:lower()--Key pressed sequence if key =='z' then--The player hits 'z' local x = Instance.new('Part', workspace)--Creates a new part x.BrickColor = BrickColor.new("Bright red")--Fire is red... x.Size = Vector3.new(10, 10, 10)--Makes the fire ball look like an actuall fire ball x.TopSurface = 'Smooth'--Removes the studs to make it look more realistic x.BottomSurface = 'Smooth'--Removes the studs to make it look more realistic x.Shape = 'Ball'--It is a fire ball... x.Name = Player.Name--this makes it so that way the fireball doesn't hurt the player using it x.CanCollide = false x.Transparency = 0.7--Make it look more realistic local fd = script.Firedamage:Clone()--Clones the fire damage for future use as well fd.Parent = x--makes firedamage apart of the fireball local y = Instance.new('BodyVelocity', x) y.maxForce = Vector3.new(math.huge, math.huge, math.huge)--Makes the fireball not too huge, but not too small y.velocity = Player.Character.Torso.CFrame.lookVector*80--Allows it to be shot from the Player's torso local f = Instance.new('Fire', x)--Adds fire to the new part f.Size = 15--Fire will be size 15 f.Heat = 0--No heat since it'll make fireball look weird x.CFrame = Player.Character.Torso.CFrame*CFrame.new(0, 0, -12)--Allows it to be shot from your character, offically... fd.Disabled = false game.Debris:AddItem(x, 1)--Removes the fire ball all together print ('Fireball successfully worked!') end--end the first argument of code chunk end--end the second argument of code chunk mouse.KeyDown:connect(onKeyDown)--Repeats function for it to be confirmed to work
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