Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

My Fireball Shooting Script Isn't Working, Help?

Asked by
Jxemes 75
7 years ago

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)
0
lmao i got the answer that i wanted but there's more than 1 mistake Jxemes 75 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

(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.

0
Thanks! It works! Jxemes 75 — 7y
0
BTW im gonna find out how to make it explode and collide it on the ground :P Jxemes 75 — 7y
0
Hey if you want help with that, i can help :D Void_Frost 571 — 7y
Ad

Answer this question