Fire Ball Doesn't Go Up Or Down

Hello! So I’m trying to make a fireball that goes up and down but It doesn’t work and errors

Script

local FireBall = script.Parent
local UpValue = 24
local DownValue = 24

local function FireBallGoBackLow()
	for i = 0.1, UpValue do
		wait(0.01)
		FireBall.Position = FireBall.Position + Vector3.new(0,1,0)
	end
end

local function FireBallGoHigh()
	for i = 0.1, DownValue do
		wait(0.01)
		FireBall.Position = FireBall.Position - Vector3.new(0,1,0)
	end
end

FireBall.Position = Vector3(26530.449, 491.5, -13710.29):Connect(FireBallGoHigh)

FireBall.Position = Vector3(26530.449, 515.5, -13710.29):Connect(FireBallGoBackLow)

Error

  13:34:29.497  Workspace.FireBall.Handler:19: attempt to call a table value  -  Server - Handler:19
  13:34:29.497  Stack Begin  -  Studio
  13:34:29.497  Script 'Workspace.FireBall.Handler', Line 19  -  Studio - Handler:19
  13:34:29.498  Stack End  -  Studio

You did Vector3 and not Vector3.new in the bottom lines.

2 Likes
  15:32:05.738  Connect is not a valid member of Vector3  -  Server - Handler:19
  15:32:05.738  Stack Begin  -  Studio
  15:32:05.739  Script 'Workspace.FireBall.Handler', Line 19  -  Studio - Handler:19
  15:32:05.739  Stack End  -  Studio

You can’t call Vector3 or connect a Vector3 value, try calling the function’s you put inside your code instead.

FireBallGoBackLow()
FireBallGoHigh()
1 Like
FireBall.Position = Vector3(26530.449, 491.5, -13710.29):Connect(FireBallGoHigh)

FireBall.Position = Vector3(26530.449, 515.5, -13710.29):Connect(FireBallGoBackLow)

I’m assuming the vector is where the ball is meant to move to?

If so, I would instead pass that vector3 through the function itself. The function should use tweeting instead of for loops, this allows you to have more smooth movement.

You can’t directly connect to a Vector3, because its a type, not an object.

1 Like

When I did this then, the fireball goes up and then down but after that the script just stops working.

local FireBall = script.Parent
local UpValue = 25
local DownValue = 25

if FireBall.Position == Vector3.new(26531.449, 495.5, -13710.29) then
	for i = 0.1, UpValue do
		wait(0.01)
		FireBall.Position = FireBall.Position + Vector3.new(0,1,0)
	end
end

if FireBall.Position == Vector3.new(26531.449, 520.5, -13710.29) then
	for i = 0.1, DownValue do
		wait(0.01)
		FireBall.Position = FireBall.Position - Vector3.new(0,1,0)
	end
end

No errors this time.

You’ll need to put it in a while true loop so that it repeats.

local FireBall = script.Parent
local UpValue = 25
local DownValue = 25

while true do
    if FireBall.Position == Vector3.new(26531.449, 495.5, -13710.29) then
	    for i = 0.1, UpValue do
		    wait(0.01)
		    FireBall.Position = FireBall.Position + Vector3.new(0,1,0)
	    end
    end

    if FireBall.Position == Vector3.new(26531.449, 520.5, -13710.29) then
	    for i = 0.1, DownValue do
		    wait(0.01)
		    FireBall.Position = FireBall.Position - Vector3.new(0,1,0)
	    end
    end
end
1 Like

@aguythatsreallybored, the script keeps exhausting and now I legit have to make it so every 1 second that the fire ball goes down, it doesn’t even go smoothly anymore and looks like the game is running on 1 FPS

EDIT: It litterly exhausts at 1 second!

I’ve rewritten the code, try this.

local TweenService = game:GetService("TweenService")
local fireball = script.Parent
local tweenInfo = TweenInfo.new(1)

local tween = TweenService:Create(fireball, tweenInfo, {Position = fireball.Position + Vector3.new(0, 25, 0)})
local tween2 = TweenService:Create(fireball, tweenInfo, {Position = fireball.Position - Vector3.new(0, 25, 0)})

while true do  
   tween:Play()
   tween.Completed:Wait()
   
   tween2:Play()
   tween2.Completed:Wait()
end
2 Likes

It works now! Thanks!