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

I need help converting this to work with filtering, please help?

Asked by 5 years ago

I do not understand how to convert this script into working with filtering enabled.

wait(5)
local tool = script.Parent
local user
local tip = tool.Tip
local change = tool.Handle.change
local shot = tool.Handle.shot
local wide = tool.Handle.wide
local e = tool.Button1
local q = tool.Button2
local mode = 1
local setting = 1
local reload = false
local ammo = tool.AmmoCharge

function onKeyDown(key,g)
    if key == "q" then
        change:Play()
        if mode == 1 then
            mode = 2
            e.BrickColor = BrickColor.new("Bright red")
        elseif mode == 2 then
            mode = 1
            e.BrickColor = BrickColor.new("Bright blue")
        end
        --print(mode)
        wait()
    elseif key == "e" then
        change:Play()
        if setting == 1 then
            setting = 2
            q.BrickColor = BrickColor.new("Bright orange")
        elseif setting == 2 then
            setting = 1
            q.BrickColor = BrickColor.new("Bright green")
        end
        --print(setting)
        wait()
    end
end

function impact(hit,h)
if mode == 1 then
if hit.Parent:IsA("Hat") == false and hit.Parent:IsA("Tool") == false and hit.Parent:IsA("HopperBin") == false then
if setting == 1 then            
h:TakeDamage(math.random (5,10))-- stun beam normal
elseif setting == 2 then
h:TakeDamage(math.random (0.4,0.4))-- wide beam normal
end             
if hit.Parent:findFirstChild("stun") == nil then
local s = script.stun:Clone()
s.Parent = hit.Parent
s.Disabled = false
s.expose.Adornee = s.Parent.Torso
s.expose.Script.Disabled = false
h.WalkSpeed = 5
end
else
if setting == 1 then
h:TakeDamage(math.random (10,15))    -- stun beam bonus
elseif setting == 2 then    
h:TakeDamage(math.random (0.8,0.8)) -- wide beam bonus
end
if hit.Parent.Parent:findFirstChild("stun") == nil then
local s = script.stun:Clone()
s.Parent = hit.Parent.Parent
s.Disabled = false
s.expose.Adornee = s.Parent.Torso
s.expose.Script.Disabled = false
h.WalkSpeed = 5
end
end
elseif mode == 2 then
if hit.Parent:IsA("Hat") == false and hit.Parent:IsA("Tool") == false and hit.Parent:IsA("HopperBin") == false then
if setting == 1 then            
h:TakeDamage(math.random (15,25))-- kill beam normal
elseif setting == 2 then
h:TakeDamage(math.random (0.7,0.7))-- kill beam normal
end             
end
else
if setting == 1 then
h:TakeDamage(math.random (20,25))    -- kill beam bonus
elseif setting == 2 then    
h:TakeDamage(math.random (0.9,0.9)) -- kill beam bonus
end
end
end

tool.Equipped:connect(function(mouse)
    user = tool.Parent
    mouse.Button1Down:connect(function()
        if user.Humanoid.Health > 0 then
            if setting == 1 and ammo.Value >= 1 then 
                if reload == false then
                    ammo.Value = ammo.Value - 1
                    shot:Play()
                    reload = true
                    local r = Ray.new(tip.CFrame.p, (mouse.Hit.p -  tip.CFrame.p).unit*300)
                    local hit,position = game.Workspace:FindPartOnRay(r, user)
                    local h = hit and hit.Parent and hit.Parent:findFirstChild("Humanoid")
                    if hit ~= nil and hit.Parent.Parent:findFirstChild("Humanoid") and hit.Parent.Parent ~= workspace then
                        h = hit.Parent.Parent:findFirstChild("Humanoid")
                    end
                    if h then
                        impact(hit,h)
                    end
                    local distance = (position - tip.CFrame.p).magnitude
                    local rp = Instance.new("Part", workspace)
                    rp.Name = "RayPart"
                    rp.BrickColor = BrickColor.new("Bright orange")
                    rp.Transparency = 0.2
                    rp.Anchored = true
                    rp.CanCollide = false
                    rp.TopSurface = Enum.SurfaceType.Smooth
                    rp.BottomSurface = Enum.SurfaceType.Smooth
                    rp.formFactor = Enum.FormFactor.Custom
                    rp.Size = Vector3.new(0.2, distance, 0.2)
                    rp.CFrame = CFrame.new(position, tip.CFrame.p) * CFrame.new(0, 0, -distance/2) * CFrame.Angles(math.rad(90),0,0)
                    local m = Instance.new("CylinderMesh", rp)
                    m.Scale = Vector3.new(0.2,1,0.2)
                    local Z = Instance.new("Part", game.Workspace)
        Z.Name = "Effect"
        Z.FormFactor = 3
        Z.CanCollide = false
        Z.Transparency = 1
        Z.Anchored = true
        Z.Size = Vector3.new(0.1,0.1,0.1)
        Z.CFrame = CFrame.new(position)
        local F = Instance.new("Fire", Z)
        F.Name = "DMGFX"
        F.Color = Color3.new(236/255,139/255,70/255)
        F.SecondaryColor = Color3.new(139/255,80/255,55/255)
        F.Size = 2
        F.Heat = 3
        local L = Instance.new("PointLight",Z)
        L.Name = "LFX"
        L.Color = Color3.new(255/255,170/255,127/255)
        L.Brightness = 1
        L.Enabled = true
        L.Range = 6
        L.Shadows = true
        game.Debris:AddItem(Z,.3)
                    local st = rp:Clone()
                    st.Parent = rp
                    if mode == 1 then
                        st.BrickColor = BrickColor.new("Bright yellow")
                    end
                    st.Mesh.Scale = Vector3.new(0.35,1,0.35)
                    st.Transparency = 0.55
                    game.Debris:AddItem(rp,0.10)
                    wait (0.2)
                    game.Debris:AddItem(Z,0.25)
                    wait(0.5)
                    reload = false
                end
            elseif setting == 2 and ammo.Value >= 19 then
                if reload == false then
                    ammo.Value = ammo.Value - 20
                    wide:Play()
                    reload = true
                    for i = -130,130 do
                        local r = Ray.new(tip.CFrame.p, ((mouse.Hit*CFrame.new(Vector3.new((0.1*i),0,0)).p) - tip.CFrame.p).unit*100)
                        local hit,position = game.Workspace:FindPartOnRay(r, user)
                        local h = hit and hit.Parent and hit.Parent:findFirstChild("Humanoid")
                        if h then
                            impact(hit,h)
                        end
                        local distance = (position - tip.CFrame.p).magnitude
                        if i == 0 then
                            local rp = Instance.new("Part", user)
                            rp.Name = "RayPart"
                            rp.BrickColor = BrickColor.new("Bright orange")
                            rp.Transparency = 0
                            rp.Anchored = true
                            rp.CanCollide = false
                            rp.TopSurface = Enum.SurfaceType.Smooth
                            rp.BottomSurface = Enum.SurfaceType.Smooth
                            rp.formFactor = Enum.FormFactor.Custom
                            rp.Size = Vector3.new(0.2, 0.2, distance)
                            rp.CFrame = CFrame.new(position, tip.CFrame.p) * CFrame.new(0, 0, -distance/2) * CFrame.Angles(300,0,0)
                            local light1 = Instance.new("SurfaceLight", rp)
                            light1.Color = Color3.new(255/255,170/255,0/255)
                            light1.Range = 8
                            light1.Shadows = true
                            light1.Face= "Back"
                            local light2 = Instance.new("SurfaceLight", rp)
                            light2.Color = Color3.new(255/255,170/255,0/255)
                            light2.Range = 8
                            light2.Shadows = true
                            light2.Face = "Bottom"
                            local light3 = Instance.new("SurfaceLight", rp)
                            light3.Color = Color3.new(255/255,170/255,0/255)
                            light3.Range = 8
                            light3.Shadows = true
                            light3.Face = "Front"
                            local light4 = Instance.new("SurfaceLight", rp)
                            light4.Color = Color3.new(255/255,170/255,0/255)
                            light4.Range = 8
                            light4.Shadows = true
                            light4.Face = "Left"
                            local light5 = Instance.new("SurfaceLight", rp)
                            light5.Color = Color3.new(255/255,170/255,0/255)
                            light5.Range = 8
                            light5.Shadows = true
                            light5.Face = "Right"
                            local light6 = Instance.new("SurfaceLight", rp)
                            light6.Color = Color3.new(255/255,170/255,0/255)
                            light6.Range = 8
                            light6.Shadows = true
                            light6.Face = "Top"
                            local m = Instance.new("SpecialMesh", rp)
                            m.MeshType = "FileMesh"
                            m.MeshId = "http://www.roblox.com/asset/?id=1033714"
                            m.Scale = Vector3.new(25,1.275*distance,0.001)
                            local st = rp:Clone()
                            st.Parent = rp
                            st.Mesh.Scale = Vector3.new(25.5,(1.275*distance)+0.5,0.101)
                            st.Transparency = 0.75
                            if mode == 1 then
                                st.BrickColor = BrickColor.new("Bright yellow")
                            end
                            game.Debris:AddItem(rp,0.5)
                        end
                    end
                    wait(5)
                    reload = false
                end
            end
        end
    end)
    mouse.KeyDown:connect(function(string) onKeyDown(string,g) end)
end)



tool.Unequipped:connect(function ()
end)

0
Learn how to use Remote functions and Remote events (I learned from https://www.youtube.com/watch?v=C0qQ4lDa3t0)and to make those secure from hacking look at https://scriptinghelpers.org/questions/65889/how-does-hacking-work-on-roblox-so-i-can-prevent-itsolved to understand how hackers hack. RichCookieGamer 7 — 5y
0
Say if you want the bullet to appear on the other clients you would use the remote event and use Remote Event:FireServer() and tell the SCRIPT to handle the damage CHECK amt of bullets you have before it does anything else etc. RichCookieGamer 7 — 5y
0
I have no idea how to do that, is there a simple way to do this, And/or can i hire one of you guys to do it. BearKranz 41 — 5y

Answer this question