Fireball script

hello yall
ive made a script to shoot fireballs. The fireballs shoot though they only shoot in one direction, even though I want it to shoto whereever the player is facing. The script is located in a tool (its local), and there are no errors in the output.

local tool = script.Parent
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local root = character:WaitForChild("HumanoidRootPart")
function OnActivation()

	print('Activation works')
	local ball = Instance.new("Part")
	ball.Shape = Enum.PartType.Ball
	ball.Color = Color3.new(1, 0.333333, 0)
	ball.Size = Vector3.new(.1,.1,.1)
	local fire = Instance.new("Fire")
	fire.Parent = ball
	ball.Parent = root
	
	local newCFrame = CFrame.new(root.Position)


	ball.CFrame = newCFrame
	
	
	local Velocity = Instance.new("BodyVelocity")

	Velocity.maxForce = Vector3.new(math.huge, math.huge, math.huge) 
	Velocity.Velocity = ball.CFrame.lookVector * 30


	Velocity.Parent = ball

end

tool.Activated:Connect(OnActivation)
1 Like

Can you send us the full script, or at least how the ball was made?

Try replacing CFrame.new(root.Position) with root.CFrame

It is already there??? I think you just missed it.

this is the full script… it makes the ball in the function

1 Like

Oh, forgot I scrolled down lol.

I found the issue, set the rotation of the ball to where you want it to face, in this case, set it to the tool rotation, if you need to adjust it tell me

Nevermind, I thought you set the position, and not the rotation, but you set the cframe.

Glad your issue was solved by @Pure_Bacn , @trueblockhead101 !

local tool = script.Parent
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local root = character:WaitForChild("HumanoidRootPart")
function OnActivation()

	print('Activation works')
	local ball = Instance.new("Part")
	ball.Shape = Enum.PartType.Ball
	ball.Color = Color3.new(1, 0.333333, 0)
	ball.Size = Vector3.new(.1,.1,.1)
        ball.CanCollide = false

	local fire = Instance.new("Fire")
	fire.Parent = ball
	ball.Parent = root

	local newCFrame = root.CFrame


	ball.CFrame = newCFrame


	local Velocity = Instance.new("BodyVelocity")

	Velocity.maxForce = Vector3.new(math.huge, math.huge, math.huge) 
	Velocity.Velocity = ball.CFrame.lookVector * 30


	Velocity.Parent = ball

end

tool.Activated:Connect(OnActivation)

I tried this and it works

Edit: I changed it up a bit to make it so that it doesnt push u back when u fire. Another note is that it is client sided.

2 Likes

Woah it works! Thanks mate.

Could you explain what you did differentley?

I set the CFrame to the root part of the player instead of whatever CFrame.new(root.Position) does (I forgor what that does lol)

o ok

Thats weird that it make s adifference since they both are supposed to do the same thing XD. But atleast it works ya know

Im pretty sure CFrame.new(root.Position) doesn’t account for the rotation. Try fact checking me on that one because i kinda forgot.

Your probably right since mine doesnt work.

You might wanna look into remote events to make it so other players can also see the fireball

Edit: you also need a debounce because if you use an autoclicker it can lag your game pretty hard, especially because they dont travel very fast and they dont “die”

I can help you with that, @trueblockhead101 but you might want to make another post for that.