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

help me with this errors in the fireball script?


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

1 comment

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. :)

1 answer

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.

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