#Other players can't hear sounds or see effects from the gun.

1 messages · Page 1 of 1 (latest)

spare sun
#

local players = game.Players.LocalPlayer
local anim1 = script.Parent.Animation
local anim2 = script.Parent.FireAnimation
local animR = script.Parent.PistolReloadAnim

local anim = script.Parent.Rest

local camera = game.Workspace.CurrentCamera

local Value = script.Parent.Value

local Value2 = Value.Value

Value.Value = 6

local track
local trackR
local track2
local trackA

local UIS = game:GetService("UserInputService")

local CanFire = false

script.Parent.Equipped:Connect(function()

    track = players.Character.Humanoid:LoadAnimation(anim1)
    track:Play()
end)


local debouce = false



local Temp = false

UIS.InputBegan:Connect(function(key)
    if players.Character:FindFirstChild("Revolver") then
        if key.KeyCode == Enum.KeyCode.E then

            if Temp == false then
                Temp = true
                print("K")
            
                trackA = players.Character.Humanoid.Animator:LoadAnimation(anim)
                trackA:Play()
            elseif Temp == true then
                Temp = false
            
                trackA:Stop()
            end
        end
    end
end)
#
UIS.InputBegan:Connect(function(key)
    if players.Character:FindFirstChild("Revolver") then
        if key.KeyCode == Enum.KeyCode.E then

            if Temp == false then
                Temp = true
                print("K")
            
                trackA = players.Character.Humanoid.Animator:LoadAnimation(anim)
                trackA:Play()
            elseif Temp == true then
                Temp = false
            
                trackA:Stop()
            end
        end
    end
end)
#
UIS.InputBegan:Connect(function(key)
    if players.Character:FindFirstChild("Revolver") then
        if key.KeyCode == Enum.KeyCode.R then
             trackR = players.Character.Humanoid:LoadAnimation(animR)
            trackR:Play()
            script.Parent.Part.RELOADSOUND:Play()
            wait(1)
            Value.Value = 6
            
        end
            end
        end)
#
script.Parent.Activated:Connect(function()
    if Value.Value > 0 then
    if debouce == false then
        debouce = true
        
        
        
        Value.Value = Value.Value - 1
    
        track2 = players.Character.Humanoid:LoadAnimation(anim2)
        track2:Play()
        
        camera.CFrame = camera.CFrame * CFrame.Angles(.005,math.rad(.5),0)
        wait(.01)
        camera.CFrame = camera.CFrame * CFrame.Angles(.0015,math.rad(.8),0)
        wait(.01)
        camera.CFrame = camera.CFrame * CFrame.Angles(.002,math.rad(.5),0)
        wait(.01)
        camera.CFrame = camera.CFrame * CFrame.Angles(-.0015,math.rad(0),0)
        wait(.01)
        camera.CFrame = camera.CFrame * CFrame.Angles(-.005,math.rad(0),0)
        wait(.01)
        camera.CFrame = camera.CFrame * CFrame.Angles(-.002,math.rad(0),0)
        

            script.Parent.Part.MuzzleLight2.Enabled = true
            script.Parent.Part.MuzzleFlash.Enabled = true
            script.Parent.Part.Muzzle.Enabled = true
            script.Parent.Part.MuzzleLight.Enabled = true
            script.Parent.Part.Muzzle1.Enabled = true
            script.Parent.Part.Muzzle2.Enabled = true
            script.Parent.Part.FIRE:Play()
            wait(.12)
            script.Parent.Part.Muzzle2.Enabled = false
            script.Parent.Part.Muzzle1.Enabled = false
            script.Parent.Part.MuzzleLight2.Enabled = false
            script.Parent.Part.MuzzleFlash.Enabled = false
            script.Parent.Part.Muzzle.Enabled = false
            script.Parent.Part.MuzzleLight.Enabled = false

 
        
    
        debouce = false
        
        
            if Value.Value < 0 then
                Value.Value = 0
                if Value.Value == 0 then
                    print("Out OF Amno")
                end
            end
        end
        
    end
end)
#
script.Parent.Unequipped:Connect(function()
    track:Stop()
    trackA:Stop()
    track2:Stop()
end)
paper crane
#

Are you playing the sound and effects all in a localscript?

spare sun
#

Yeah

paper crane
#

thats why

spare sun
#

I figured out the problem but theres still a bug

#

I made a server side script and used a remote event

paper crane
#

yeah

spare sun
#

but the player can still see the effects even after the amno is gone

#


local Value
local debouce = false

local Value = script.Parent.Value



script.Parent.RemoteEvent.OnServerEvent:Connect(function(player)
    
    script.Parent.Activated:Connect(function()
        if Value.Value > 0 then
            if debouce == false then
                debouce = true

script.Parent.Part.MuzzleLight2.Enabled = true
script.Parent.Part.MuzzleFlash.Enabled = true
script.Parent.Part.Muzzle.Enabled = true
script.Parent.Part.MuzzleLight.Enabled = true
script.Parent.Part.Muzzle1.Enabled = true
script.Parent.Part.Muzzle2.Enabled = true
script.Parent.Part.FIRE:Play()
wait(.12)
script.Parent.Part.Muzzle2.Enabled = false
script.Parent.Part.Muzzle1.Enabled = false
script.Parent.Part.MuzzleLight2.Enabled = false
script.Parent.Part.MuzzleFlash.Enabled = false
script.Parent.Part.Muzzle.Enabled = false
script.Parent.Part.MuzzleLight.Enabled = false

                debouce = false

         end
         end
end)

end)
#

Sevrer side script

paper crane
low prairie
spare sun
low prairie
paper crane
paper crane
#

you can just do

robust swanBOT
#

studio** You are now Level 3! **studio

paper crane
#

local Main = script.Parent

for _, v in Main:GetDescendants() do

if v:IsA("ParticleEmitter") then
    v.Enabled = true
end

end

spare sun
#

Ah

paper crane
#

or in your case do script.Parent.Part

#

also why are you enabling them instead of doing Particle:Emit()

spare sun
#

Whats the difference?

paper crane
#

You can choose how much particles you want to emit

#

like PartileEmitter:Emit(5)

#

it emits 5 particles

#

you'd have to set the rate to 0 and have the particleemitter enabled

paper crane
#

script.Parent.RemoteEvent.OnServerEvent:Connect(function(player)

script.Parent.Activated:Connect(function()
    if Value.Value > 0 then
        if debouce == false then
            debouce = true

            for _, v in script.Parent.Part:GetDescendants() do
                if v:IsA("ParticleEmitter") then
                    v:Emit(5)
                end
            end

            debouce = false

        end
    end
end)

end)

spare sun
#

Oh wait

paper crane
#

yeahn

spare sun
#

Particles still emit even after value = 0

paper crane
#

can i see

spare sun
#

The local script works, you can see because the animation stopped playing as it should

#

but the effects continue even after the value is 0

paper crane
#

are you checking if its value is 0

spare sun
#

if Value.Value > 0 then

paper crane
#

try >=

#

its basically if value is greater than or equal to 0

spare sun
#

if the value equals zero the effects shouldn't play, so saying >= would still make it play because the value = 0

low prairie
paper crane
low prairie
paper crane
#

not really thats just what makes it more motivating to finish unless it requires a whole lotta math

spare sun
#

ye

paper crane
#

I mean you can just do if value.value >= 1 then

spare sun
#

The particles still emit sad

low prairie
#

ay is it hard to design like your own gun

#

and can u even do that on roblox studio?

paper crane
#

Yeah but its not the best

#

I'd probably just use blender

#

takes time to learn it tho

spare sun
paper crane
#

if Value.Value < 0 then
Value.Value = 0
if Value.Value == 0 then
print("Out OF Amno")
end
end
why are you setting it to 0?

spare sun
#

Because the value subracts with each click

#

if it isn't set to 0, it'll go to -1

#

and the whole script goes crazy when the value is set to -1

paper crane
#

I think you did something wrong it should stop when it reaches zero

spare sun
#

In the old script, before the remote event, it did stop

#

the script isn't even detecting the value or somthing

paper crane
#

local debouce = false

script.Parent.Activated:Connect(function()
if Value.Value >= 1 then
debouce = true

        Value.Value = Value.Value - 1

        for _, v in script.Parent.Part:GetDescendants() do
            if v:IsA("ParticleEmitter") then
                v:Emit(5)
            end
        end
        
        wait(.5)

        debouce = false
        
        if Value.Value == 0 then
            debouce = true
            wait(1)
            Value.Value +=  -- the amount of bullets in your gun
            debouce = false
        end
        
end

end)

robust swanBOT
#

studio** You are now Level 4! **studio

spare sun
#

I just figured out what was the problem

paper crane
#

dang

#

I had to open up studio for it

spare sun
#

It works now, I needed to subtract the value in the server side script aswell

paper crane
#

alr well ima get going

spare sun
#

Thank you for the help 🔥