Fireball object doesnt follow fireball position

Okay so the velocity does go to where the player is looking however, it still just sits there if it doesnt hit anything

1 Like

Alright try this, it should theoretically work, I’ve added some prints to see any potential errors we might encounter

LocalScript

local player = game.Players.LocalPlayer
local Fireball = player:WaitForChild("Backpack").Fireball
local BallEvent = game.ReplicatedStorage.FireballEvent
local Debounce = false
local Cooldown = 0.5 
local mouse = player:GetMouse()
local inputservice = game:GetService("UserInputService")

inputservice.InputBegan:Connect(function(input, gpe)
	if input.KeyCode == Enum.KeyCode.E and not gpe then
		if player.Character:FindFirstChild("Fireball") and player.Character.Fireball:IsA("Tool") then

			if Debounce == false then
				print("Firing fireball...")

				Debounce = true
				BallEvent:FireServer(mouse.Hit.p)

				wait(Cooldown)
				Debounce = false
			else
				print("Fireball on cooldown.")
			end

		else
			print("Fireball tool not found.")
		end

	end
end)

script Server

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FireballEvent = ReplicatedStorage.FireballEvent

local function createFireball(player, targetPosition)
	print("Creating fireball for player:", player.Name)

	local clonedFireball = game.ReplicatedStorage.Fireball:Clone()
	local CF = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0.5, -4)

	clonedFireball.Parent = workspace
	clonedFireball.CFrame = CF

	print("Fireball position set.")

	local velocityDirection = (targetPosition - clonedFireball.Position).unit

	local BodyVelocity = Instance.new("BodyVelocity")
	BodyVelocity.Velocity = velocityDirection * 100
	BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	BodyVelocity.Parent = clonedFireball

	print("Fireball velocity set.")

	clonedFireball.Touched:Connect(function(hit)
		print("Fireball touched something.")

		if hit.Parent:FindFirstChild("Humanoid") and not hit:IsDescendantOf(player.Character) then
			hit.Parent.Humanoid:TakeDamage(40)
			clonedFireball:Destroy()
		elseif not hit.Parent:FindFirstChild("Humanoid") then
			local Explosion = Instance.new("Explosion")
			Explosion.Parent = workspace
			Explosion.ExplosionType = Enum.ExplosionType.NoCraters
			Explosion.BlastRadius = 3
			Explosion.DestroyJointRadiusPercent = 0
			Explosion.Position = clonedFireball.Position
			clonedFireball:Destroy()
		end
	end)
end

FireballEvent.OnServerEvent:Connect(createFireball)
1 Like


image

1 Like

are u sure ur Fireball is not anchored ??

1 Like

1 Like


certain

1 Like

even if i just swap it out for a standard part, it still does the same

1 Like

put ur fireballscript on a tool for try

1 Like

still does the same thing. this actually makes no sense

1 Like

maybe i can add you to team create and see if you can find the issue

1 Like

yeah i think its a good idea do that

1 Like

ive got to add you quickly first so i can make you edit

1 Like
1 Like

the fireball work for me :rofl: ahah try too

1 Like

it might be a visual thing for me then

1 Like

1 Like

Yes, maybe restart your Roblox Studio, the code I’ve fixed indeed works well

1 Like

i restarted studio and it still does it but when i go ingame it works!!

1 Like

perfect! in the script, i added a maximum distance so that the fireball eventually gets destroyed to prevent it from wandering in space forever

1 Like

thank you for that, it would probably help prevent lag

1 Like