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

My Fireball Shooting Script Isn't Working, Help?

I've been trying to make a game that is similar to Elemental Battlegrounds. I got a HopperBin, and a script I made. The problem is that it won't shoot. Anyone got any ideas?

local me = game.Players.LocalPlayer
local tool = script.Parent

local ws = game:GetService("Workspace")

tool.Selected:connect(function(mouse) 
mouse.Button1Down:connect(function()

handle = me.Character.Torso

local p = Instance.new("Part")
p.CFrame = CFrame.new(handle.Position)
p.TopSurface = "Smooth" 
p.BottomSurface = "Smooth" 
p.Shape = Enum.PartType.Ball 
p.Size = Vector3.new(2,2,2) 
p.CanCollide = false
p.BrickColor = BrickColor.new("Really red")
p.Parent = ws

local bv = Instance.new("BodyVelocity")
bv.Parent = p 
bv.velocity = (mouse.Hit.p - handle.Position).unit*90

p.Touched:connect(function(hit)
if hit.Parent.Name ~= me.Character.Name then
hit.Parent.Humanoid:TakeDamage(5)
end
end)
game:GetService("Debris"):AddItem(p, 7)
end)
end)

1 comment

0

lmao i got the answer that i wanted but there's more than 1 mistake

1 answer

✓ Accepted answer

(Hope you don't mind, but i added R15 compatibility.)

local me = game.Players.LocalPlayer
local tool = script.Parent

local ws = game:GetService("Workspace")

tool.Equipped:connect(function(mouse) 
mouse.Button1Down:connect(function()

handle = me.Character:FindFirstChild("Torso")
if handle== nil then
handle=me.Character.UpperTorso
end

local p = Instance.new("Part")
p.CFrame = CFrame.new(handle.Position)
p.TopSurface = "Smooth" 
p.BottomSurface = "Smooth" 
p.Shape = Enum.PartType.Ball 
p.Size = Vector3.new(2,2,2) 
p.CanCollide = false
p.BrickColor = BrickColor.new("Really red")
p.Parent = ws

local bv = Instance.new("BodyVelocity")
bv.Parent = p 
bv.velocity = (mouse.Hit.p - handle.Position).unit*90

p.Touched:connect(function(hit)
if hit.Parent.Name ~= me.Character.Name then
hit.Parent.Humanoid:TakeDamage(5)
end
end)
game:GetService("Debris"):AddItem(p, 7)
end)
end)

Use a tool, not a hopperbin. In the properties window, change the RequiresHandle Property of the tool to false.

3 comments

0

Thanks! It works!

0

BTW im gonna find out how to make it explode and collide it on the ground :P

0

Hey if you want help with that, i can help :D

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