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

My Gun script is not creating a bullet neither shooting?

Asked by 7 years ago
Edited 7 years ago

I don't know if my code is incomplete or it's just not it I shoot and it won't shoot any bullet do I need some CFrame or different properties please help me?

--Made By johndeer2233
player = game.Players.LocalPlayer
mouse = player:GetMouse()
tool = script.Parent
AnimationIdle = script:WaitForChild("IdleGun")
idleenabled = true
enabled = true
ChamberGun = script.Parent.ChamberGun

--All the Animations
script.Parent.Equipped:connect(function()
       if enabled then
        enabled = false
        local AnimationTrackIdle = player.Character.Humanoid:LoadAnimation(script.IdleGun)
        AnimationTrackIdle:Play()
        print("It Worked!")
    end
    wait(5)
    enabled = true
end)
-- When SHooting
mouse.Button1Down:connect(function()
    local bullet = Instance.new("Part")
    bullet.Shape = "Ball"
    bullet.Size = Vector3.new(0.6, 0.6, 0.6)
    bullet.BrickColor = BrickColor.new("Medium Stone Grey")
    bullet.Position = ChamberGun.Position
    bullet.Velocity = Vector3.new(-100,0,0)
        bullet.Parent = ChamberGun
end)

There is no error in the output and the chamber gun position is the end of the gun and different part as well as it is set to CanCollide = false

0
You're not setting where to Exactly to Shoot at. GeezuzFusion 200 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

I hope you know how to dissect scripts, but here this could help you

local Tool = script.Parent
-- WebBall is the projectile created through "Instance.new()"
function shoot(v)
    local bullet = WebBall:Clone()

    local Character = tool.Parent
    local Head = Character:FindFirstChild("Head")
    bullet.Parent = workspace
    local launch = Head.Position + 10 * v
    bullet2.CFrame = CFrame.new( launch, launch + v)
    bullet.Velocity = v * 100
end

function fire()
    local Character = tool.Parent
    local Humanoid = Character:FindFirstChild("Humanoid")
    local look = (Humanoid.TargetPoint - Character:FindFirstChild("Head").Position).unit
    shoot(look)
end
Tool.Activated:connect(fire)

0
Just a quick question where do you declare v as a variable johndeer2233 439 — 7y
0
Where is weball declared to johndeer2233 439 — 7y
0
Sorry, I fixed it now. GeezuzFusion 200 — 7y
Ad

Answer this question