✓ Accepted answer
This is close to being right. There are three problems I see:
X is never given a position, so it's probably in some random space in the center of the baseplate.
Players is not defined.
The property is LocalPlayer not Player
And also a few things to help clean it up a little.
To elaborate:
Unlike Workspace, the Players service doesn't have a variable already given to you. You have to explicitly use game.Players (see line 13).
And, the local player is .LocalPlayer not .Player (also line 13). (This script will only work as a LocalScript and without FilteringEnabled)
To give X its position, you could do something like
X.Position = game.Players.LocalPlayer.Character.Torso.Position
+ game.Players.LocalPlayer.Character.Torso.CFrame.lookVector * 3
To place it a few studs in front of the player.
Since we would then be referring to the torso object 3 times, it would probably be better to define a variable for it.
function FireBall()
local torso = game.Players.LocalPlayer.Character.Torso
...
Y.Velocity = torso.CFrame.lookVector * 80
...
X.Position = torso.Position + torso.CFrame.lookVector * 3
...
One more convenient detail. Instead of having a line to set the parent of a new object (lines 14, 15 in your snippet) you can use the second parameter to Instance.new:
local X = Instance.new("Part", Workspace)
...
local Y = Instance.new("BodyVelocity", X)
2 comments
Players.Player1.Backpack.LocalScript:2: attempt to index global 'Player' (a nil value) This is All I'm Getting
If you are getting that error then you did not address
PlayervsLocalPlayercorrectly. Refer to what I have written.