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

Why doesn't my Fireball script not work?

Asked by 10 years ago

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

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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.

0
Oh, i'm so stupid to even not recognize that! I'd never made a mistake like that before lol! Operation_Meme 890 — 10y
0
is there any other problems? Operation_Meme 890 — 10y
0
I caught two more things BlueTaslem 18071 — 10y
0
I dont get the color part. range of R,G and B are [0,1]? Not [0,255]? Operation_Meme 890 — 10y
0
Use 0.5, not 127 BlueTaslem 18071 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

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

0
Doesn't the f.CFrame = head.CFrame do that already? Operation_Meme 890 — 10y
0
nope Prince67891 0 — 9y
Log in to vote
0
Answered by 10 years ago

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
0
I'm going to make the flying part later on. Operation_Meme 890 — 10y
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. Operation_Meme 890 — 10y

Answer this question