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

Why doesn't my Fireball script not work?

Okay, so i've made a fireball script for a dragon. When test it, on output it says did you forget a colon? The first argument of WaitForChild must be an Object. And here's the script:

sp = script.Parent
head = script.Parent.WaitForChild("Head")

function fire()
	f = Instance.new("Part")
	f.Name = "fireball"
	f.Shape = "Ball"
	f.BrickColor = BrickColor.new("Bright blue")
	f.TopSurface = "Smooth"
	f.BottomSurface = "Smooth"
	f.Size = Vector3.new(3,3,3)
	f.CanCollide = false
	f.CFrame = head.CFrame
	f.Velocity = head.CFrame.lookVector*math.random(60,100)
	g = Instance.new("Fire", fireball)
	g.Heat = 5
	g.Color = Color3.new(255,0,0)
	g.SecondaryColor = Color3.new(85,85,85)
	fireball.Parent = game.Workspace
end

while true do
	wait()
	fire()
end

3 answers

✓ Accepted answer

WaitForChild is a method. Methods use a : instead of .:

head = script.Parent:WaitForChild("Head")

Other typo: You use fireball in two places; fireball was never defined. Those should be replaced with f which is used everywhere else.


Color3s are not BrickColors. Use Color.new(r,g,b) to make Color3 values. Note that the range of R, G, and B are [0, 1] not [0,255] like that shown in the properties window. Divide each value by 255 to get the correct decimal.

5 comments

0

Oh, i'm so stupid to even not recognize that! I'd never made a mistake like that before lol!

0

is there any other problems?

0

I caught two more things

0

I dont get the color part. range of R,G and B are [0,1]? Not [0,255]?

0

Use 0.5, not 127

You forgotten to Anchored the fireball and to make it shoot do this Make sure the fireball is to the dragon mouth like CFrame it to the dragon mouth for i = 1,100 do f.CFrame = f.CFrame *CFrame.new(0,0,-5) wait(0.03) end

2 comments

0

Doesn't the f.CFrame = head.CFrame do that already?

0

nope

Why is it looped, That will lag out your game. Also, it would not fly if you fixed your problem, use this instead.

bv = Instance.new("BodyVelocity")
bv.maxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.velocity = part.CFrame.lookVector*speed

2 comments

0

I'm going to make the flying part later on.

0

Oh and, for the fly i'm making a BodyGyro and a BodyPosition.. Then make it follow the player, so when you want it to shoot, you click somewhere and it shoots there.

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