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