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

Filtering Enabled Gun is Broken?

Asked by 8 years ago

Well, I am kinda new to FilteringEnabled, and currently I'm trying to convert my gun to work with FIlteringEnabled, I've had a friend help me, but until now I still can't get the gun to work, If any of you could show me what I did wrong :/

here is the Local script

Player = game.Players.LocalPlayer
Pistol1 = script.Parent
Ammo = 11
Mouse = Player:GetMouse()
shoot = false
reloading = false
MaxAmmo = 11
Mouse = Player:GetMouse()


function FireShooting()
    game.Workspace.ShootingServerEvent:FireServer(Mouse.hit.p)
            game.Players.LocalPlayer.PlayerGui.HUDs.PlayerHUD.Manabar.Ammobar.Size = UDim2.new((Ammo / MaxAmmo),0,1,0)
            local ammoy = Ammo
            game.Players.LocalPlayer.PlayerGui.HUDs.PlayerHUD.Manabar.Ammonum.Text = ammoy.."/"..MaxAmmo    
end

Pistol1.Activated:connect(FireShooting)


and here is the script for the gun

Player = script.Parent.Parent.Parent
Pistol1 = script.Parent
Ammo = 11
Mouse = Player:GetMouse()
shoot = false
reloading = false
MaxAmmo = 11
---------------------------------------------------------Shooting Scripts(doesn't work)--------------------------------------------------------------
local shootevent = Instance.new("RemoteEvent", workspace)
shootevent.Name = "ShootingServerEvent"


function Shooting(mousepos)
    if Ammo > 0 and shoot == false then
        shoot = true
        --Raycasting thing
            local ray = Ray.new(Pistol1.Main.CFrame.p, (mousepos - Pistol1.Main.CFrame.p).unit * 113)
            local part, position = workspace:FindPartOnRay(ray, Player.Character, false, true)
        --Bullet Properties
            local Bullet = Instance.new("Part", workspace)
            Bullet.FormFactor = "Custom"
            Bullet.Material = "Neon"
            Bullet.BrickColor = BrickColor.new("Toothpaste")
            Bullet.CanCollide = false
            Bullet.Anchored = true
        --CFraming Stuffs
            local distance = (Pistol1.Main.CFrame.p - position).magnitude
            Bullet.Size = Vector3.new(0.1, 0.1, distance)
            Bullet.CFrame = CFrame.new(Pistol1.Main.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
            game:GetService("Debris"):AddItem(Bullet, 0.5)
        --Second Bullet
            local ray2 = Ray.new(Pistol1.Main2.CFrame.p,(mousepos - Pistol1.Main2.CFrame.p).unit *113)
            local part, position = workspace:FindPartOnRay(ray, Player.Character, false, true)
        --Second Bullet Properties
            local Bullet2 = Instance.new("Part", workspace)
            Bullet2.FormFactor = "Custom"
            Bullet2.Material = "Neon"
            Bullet2.BrickColor = BrickColor.new("Toothpaste")
            Bullet2.CanCollide = false
            Bullet2.Anchored = true
        --CFrameing Stuffs for 2nd Bullet
            local distance2 = (Pistol1.Main2.CFrame.p - position).magnitude
            Bullet2.Size = Vector3.new(0.1, 0.1, distance2)
            Bullet2.CFrame = CFrame.new(Pistol1.Main2.CFrame.p, position) * CFrame.new(0, 0, -distance2 / 2)
            game:GetService("Debris"):AddItem(Bullet2, 0.5)
        --Bullet Stuff Damage, Ammo, Velocity
            Ammo = Ammo - 1
                        if part then

                            --Looking for humanoid
                            local humanoid = part.Parent:FindFirstChild("Humanoid")


                                --If there is no humanoid then it will check the part that got hit's Parent's Parent and see if that has a humanoid aswell
                            if not humanoid then
                                part.Parent.Parent:FindFirstChild("Humanoid")
                            end


                                --If there is a humanoid, then it will damage the player
                            if humanoid then
                                humanoid:TakeDamage(math.random(13, 22))
                            end


                        end

            wait(0.15)
            Bullet.Transparency = (0.8)
            Bullet2.Transparency = (0.8)
            wait(0.15)
            Bullet.Transparency = (0.6)
            Bullet2.Transparency = (0.6)
            wait(0.15)
            Bullet.Transparency = (0.4)
            Bullet2.Transparency = (0.4)
            wait(0.15)
            Bullet.Transparency = (0.2)
            Bullet2.Transparency = (0.2)
            wait(0.15)
            Bullet.Transparency = (0)
            Bullet2.Transparency = (0)

            shoot = false
    end
end

shootevent.OnServerEvent:connect(Shooting)
-----------------------------------------------------------

Answer this question