Hello Developers!
As the title states, I want to modify the script below to shoot bullets where your mouse Is at
local Tool = script.Parent
Tool.RemoteEvent.OnServerEvent:Connect(function()
local Ball = Instance.new("Part",game.Workspace)
local CanDamage = true
game:GetService("Debris"):AddItem(Ball,3)
Ball.Position = Tool.Handle.Position
Ball.Orientation = Tool.Parent.Torso.Orientation
Ball.Size = Vector3.new(1.02, 1.02, 1.02)
Ball.CastShadow = false
Ball.Anchored = false
Ball.Material = Enum.Material.Grass
Ball.Shape = Enum.PartType.Ball
Tool.Handle.Fire:Play()
Tool.Handle.Attachment.Fire.Enabled = true
Tool.Handle.Attachment.PointLight.Enabled = true
Ball.Touched:Connect(function(hit)
local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if Player then
local player1 = game.Players:GetPlayerFromCharacter(hit.Parent)
local player2 = game.Players:GetPlayerFromCharacter(Tool.Parent)
if (player1 ~= nil) and (player2 ~= nil) then
local humanoid = (player1.Character or player1.CharacterAdded:Wait()):FindFirstChildWhichIsA("Humanoid")
if (player1.TeamColor ~= player2.TeamColor) then
if (humanoid ~= nil) and CanDamage == true then
humanoid:TakeDamage(15)
CanDamage = false
end
end
end
elseif not Player then
local humanoid = hit.Parent:WaitForChild("Humanoid")
if humanoid and CanDamage == true then
humanoid:TakeDamage(15)
CanDamage = false
end
end
end)
local KnockBack = Instance.new("VectorForce")
local Attachment = Instance.new("Attachment")
KnockBack.Parent = Ball
Attachment.Parent = Ball
KnockBack.Attachment0 = Attachment
KnockBack.ApplyAtCenterOfMass = true
KnockBack.Force = Vector3.new(0,300,-6000)
game:GetService("Debris"):AddItem(KnockBack,.05)
game:GetService("Debris"):AddItem(Attachment,.05)
wait(0.1)
Tool.Handle.Attachment.Fire.Enabled = false
Tool.Handle.Attachment.PointLight.Enabled = false
end)

3 comments
How can I do that?
do you have discord? because it would be pretty annoying to text back and back hours of interval my user is eeeee#6221
you might also consider watching a how to make gun vid it have the things you need