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

help me with this errors in the fireball script?

Asked by 8 years ago

Player = script.Parent.Parent mouse = Player:GetMouse()

function onKeyDown(key) key = key:lower() if key == "f" then x = Instance.new("Part") x.BrickColor = BrickColor.new("Bright red") x.Size = Vector3.new(10, 10, 10) x.TopSurface = "Smooth" x.BottomSurface = "smooth" x.Shape = "Ball" x.Transparency = 0.7 y = Instance.new("BodyVelocity") y.maxForce = Vector3.new(math.huge, math.huge, math.huge) y.Velocity = Player.Character.Torso.CFrame.lookVector *80 x.Parent = Workspace y.Parent = x f = Instance.new("Fire",x) f.Size = 12 f.Heat = 0 game.Debris.AddItem(x, 6) end end

mouse.KeyDown:connect(OnKeyDown)

19:16:24.821 - Attempt to connect failed: Passed value is not a function 19:17:14.066 - attempt to call a nil value

0
Just a tip, theres a blue button above the text box that says "Lua" when posting question. You can paste all your code inside the little area it creates. It makes it much easier to read the code. :) AwsomeSpongebob 350 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

Remember, Lua is CASE-SENSITIVE. The function you created is called onKeyDown, but your calling OnKeyDown. You have to call it with the O lower case.

There are a couple of other errors in your code, the first being you make the BottomSurface of the part "smooth", when it needs to be "Smooth". Also AddItem is a method of Debris, so you need a : not a .

Also, the method of detecting key presses is deprecated, so it recommended you use UserInputService or ContextActionService instead. Look those up in the wiki if your interested.

Ad

Answer this question