The gun works just about as needed, the only problem is that after you’ve fired all 6 rounds. and reloaded, the value shows 6, then you fire and it goes instantly to 0 and the effects do not play after.
I’ve tried at this for hours, and i’m resorting to the dev forum for help.
--server side script
local Value
local debouce = false
local Value = script.Parent.Value
local UIS = game:GetService("UserInputService")
script.Parent.Activated:Connect(function()
if Value.Value > 0 then
if debouce == false then Value.Value = Value.Value - 1
debouce = true
print(Value.Value)
script.Parent.Part.FIRE:play()
for _, v in script.Parent.Part:GetDescendants() do
if v:IsA("ParticleEmitter") then
v:Emit(5)
end
end
debouce = false
end
end
end)
--Client Side script
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
local Event = script.Parent.RemoteEvent
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.R then
trackR = players.Character.Humanoid:LoadAnimation(animR)
trackR:Play()
script.Parent.Part.RELOADSOUND:Play()
wait(1)
print("Reloaded")
Value.Value = 6
end
end
end)
script.Parent.Activated:Connect(function()
if Value.Value > 0 then
if debouce == false then
debouce = true
Event:FireServer()
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)
wait(.12)
debouce = false
if Value.Value < 0 then
print("Out of Amno Too")
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)