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

How would I make this fireball aim-able?

I have a simple-ish script making the player shoot fireballs when clicked, the fireball just gets the rootparts position and fires it out of the torso but it only flys out and is not aim-able how would I make it aim-able? Do you have to use mouse.hit.p? halp also how would I make it so the fireball despawns and it doesn't effect the debounce wait

local tool = script.Parent
local anim = tool:WaitForChild('Burst')
local plyr = game:GetService('Players').LocalPlayer
local mouse = plyr:GetMouse()
local char = plyr.Character
local firesound = tool:WaitForChild('Sound')
local explosion = tool:WaitForChild('Sound2')
local human = char:WaitForChild('Humanoid')
local rootpart = char:WaitForChild('HumanoidRootPart')
local debounce = false

function creation()
	local brick = Instance.new('Part', workspace)
	brick.Anchored = true
	brick.Size = Vector3.new(4,4,4)
	brick.CanCollide = false
	brick.Material = 'Neon'
	brick.BrickColor = BrickColor.new('Bright red')
	brick.Orientation = rootpart.Orientation
	brick.Position = rootpart.Position + Vector3.new(0,1,0)
	local mesh = Instance.new('SpecialMesh', brick)
	mesh.MeshType = 'Sphere'
	local vel = Instance.new("BodyVelocity")
	vel.velocity = rootpart.CFrame.lookVector * 150
	vel.maxForce = Vector3.new(4e+005,4e+005,4e+005) * 10000 -- pushbackmount
	vel.Parent = brick
	brick.Anchored = false
end

local active = false
tool.Activated:connect(function()
	if debounce == false then
		debounce = true
		active = true
		local f = firesound:Clone()
		f.Parent = rootpart
		f:Play()
		local animation = human:LoadAnimation(anim)
		animation:Play()
		creation()
		wait(.2)
		f:Destroy()
		wait(.5)
		debounce = false
		active = false
	end
end)

2 comments

0

a easier way to get the local plyer is "game.Players.LocalPlayer"

0

^ makes me feel better with game:GetService

1 answer

✓ Accepted answer

Yes, you would need to use mouse.hit.p to aim.

brick.CFrame = Part.CFrame -- change part with where the ball with start at
brick.CFrame = Cframe.new(brick.Position,mouse.Hit.p)

Judging by your code, you would want to place it just before the bodyvelocity.

This will allow us to adjust both the position and angle of the brick to match up with that of the mouse.

Hope this helps!

  • PluginFactory

1 comment

0

thanks !

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