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

Why is it So that my Filtering Enabled Gun Works in Studio, but not in the Real Game?

Asked by 6 years ago

My filtering enabled gun works fine in studio, but the bullet just floats in game. I need some help

Would it be that my filtering enabled gun script shouldn't be in the workspace, or is there another problem?

Local Script for Gun Tool

Player = game.Players.LocalPlayer
local Gui
Ammo = 10
script.Parent.Equipped:connect(function(Mouse)
    Gui = script.Parent.AmoGui:clone()
    Gui.Parent = Player.PlayerGui
    Mouse.Button1Down:connect(function()
        if Ammo > 0 then
            workspace.FE.PistolShot.Shot:FireServer()
            Ammo = Ammo - 1
            Gui.BG.Text.Text = Ammo.."/10"
        end
    end)
    Mouse.KeyDown:connect(function(Key)
        if Key == "r" and Ammo < 10 then
            Gui.BG.Text.Text = "Reloading..."
            workspace.FE.PistolShot.Reload:FireServer()
            wait(1)
            Ammo = 10
            Gui.BG.Text.Text = Ammo.."/10"
        end
    end)
end)
script.Parent.Unequipped:connect(function()
    Gui:remove()
end)

Script for Shooting Gun

local Bullet
script.Shot.OnServerEvent:connect(function(Client)
    local R = script.GunShot:clone()
    R.Parent = Client.Character.Pistol.Handle
    R:Play()
    Bullet = Instance.new("Part", workspace)
    Bullet.Size = Vector3.new(1, 1, 1)
    Bullet.Transparency = 1
    local Trail = script.Beam:Clone()
    Trail.Parent = Bullet
    Trail.Enabled = true
    local A0 = Instance.new("Attachment", Client.Character.Pistol.Handle)
    local A1 = Instance.new("Attachment", Bullet)
    Trail.Attachment0 = A0
    Trail.Attachment1 = A1
    Bullet.CFrame = Client.Character.Pistol.Handle.CFrame
    local Shoot = Instance.new("BodyVelocity", Bullet)
    Bullet.Anchored = false
    Bullet.CanCollide = false
    Shoot.Velocity = CFrame.new(Bullet.CFrame.p, Client:GetMouse().Hit.p).lookVector * 900
    Shoot.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
    Bullet.Touched:connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") ~= nil then
            if hit.Parent.Name ~= Client.Name then
                Bullet.Anchored = true
                if hit.Name ~= "Head" then
                    hit.Parent.Humanoid:TakeDamage(10)
                elseif hit.Name == "Head" then
                    hit.Parent.Humanoid:TakeDamage(50)
                end
                Bullet:remove()
                hit.Parent.Killer.Value = Client.Name
            end
        end
    end)
    game:GetService("Debris"):AddItem(Bullet, 1)
end)
script.Reload.OnServerEvent:connect(function(Client)
    local R = script.ReloadSound:clone()
    R.Parent = Client.Character.Pistol.Handle
    R:Play()
end)
0
Any errors in game? You can open up the dev console and look for errors by saying "/console" in chat. dispeller 200 — 6y
0
Nope, all fine, tried that OFanTDMO 50 — 6y

Answer this question