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

How can i make my i fireball to go where i point with my mouse?

So I try to make my fireball to follow my mouse when it is fired? I don't how I can make it. Pls help The fireball script

--Made by tecady2111--
----------------------------------------Declaring Variables--------------------------------
-------------------------------------------------------------------------------------------
local disappear = 0.75
local damage = 2.5
local key = 'q' 
local speed = 200
local debounce = false
local animon = false
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=1137191839"
local Player = game.Players.LocalPlayer 
local Character = Player.Character 
local Mouse = Player:GetMouse()
local humanoid = Player.Character:FindFirstChild("Humanoid")
-------------------------------------------------------------------------------------------
 
function onKeyDown(keyx) 
	if keyx == key:lower() and debounce == false and animon == false then
		--Animation part--		
		debounce = true 
		local playAnim = humanoid:LoadAnimation(anim)
		playAnim:Play()
		animon = true
		wait (0.5)
		animon = false
		--Creating the fireball
		local x = Instance.new("Part") 
		x.Material = Enum.Material.Neon
		x.Shape = "Ball"
		x.Size = Vector3.new(10,10,10)
		game.Debris:AddItem(x, disappear)
		x.CanCollide = false
		x.BrickColor = BrickColor.new("Daisy orange") 
		--Fire for the ball--		
		local f = Instance.new("Fire") 
		f.Parent = x 
		f.Size = 30 
		f.Heat = 30
		--Making the ball move--		
		local y = Instance.new("BodyVelocity") 
		y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
		y.velocity = Character.Torso.CFrame.lookVector*speed
		y.Parent = x  
		--Parent for the fireball--		
		x.Parent = workspace 
		x.CFrame = Character.Torso.CFrame*CFrame.new(1, 1, -3)
		--Damage part--		
		x.Touched:connect(function(Part)
			if Part.Parent:findFirstChild("Humanoid") and Part.Parent.Name ~= Player.Name then
				Part.Parent.Humanoid:TakeDamage(damage)
			end
		end)
		--Antispam part ending--		
		wait (0.5)
		debounce = false
	end 
end 
Mouse.KeyDown:connect(onKeyDown)
--Made by tecady2111--



1 comment

0

Putiting in all of those dashes is really not needed

1 answer

✓ Accepted answer
	local mouse = game.Players.LocalPlayer:GetMouse()
	x.CFrame = Character.Torso.CFrame*CFrame.new(1, 1, -3)
        local y = Instance.new("BodyVelocity")
        y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
        y.velocity = (x.Position - mouse.hit.p).unit * 175

2 comments

0

It shoots in the opposite direction

0

then do -175

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