im using fastcast so some of the firing is different
game:GetService("UserInputService").MouseIconEnabled = false
--guns
local grozamodel = game.ReplicatedStorage:WaitForChild("Weapons"):WaitForChild("Groza")
local settings = require(grozamodel.GunComponents.Settings)
--animations
local viewmodel = game.ReplicatedStorage:WaitForChild("Viewmodel")
local animations = game.ReplicatedStorage:WaitForChild("Animations")
local groza = animations:WaitForChild("Groza")
--modules
local module = require(game.ReplicatedStorage.Modules.MainModule)
local spring = require(game.ReplicatedStorage.Modules.SpringModule)
local event = game.ReplicatedStorage:WaitForChild("Event")
viewmodel.Parent = game.Workspace.Camera
module.weldgun(grozamodel)
local recoil = spring.new()
local bobble = spring.new()
local sway = spring.new()
game:GetService("RunService").RenderStepped:Connect(function(dt)
module.update(viewmodel, dt, recoil, bobble, sway, grozamodel)
end)
module.equip(viewmodel, grozamodel, groza, settings)
local md
local canfire = true
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
md = true
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
module.aim(true, viewmodel, grozamodel)
end
end)
game:GetService("UserInputService").InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
md = false
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
module.aim(false, viewmodel, grozamodel)
end
end)
local function reloadsound()
local reloadsound = grozamodel.GunComponents.Sounds.Reload:Clone()
reloadsound.Parent = game.Workspace
reloadsound:Destroy()
end
game:GetService("ContextActionService"):BindAction("Reload", function(name, state, input)
if state == Enum.UserInputState.Begin then
module.aim(false, viewmodel, grozamodel)
module.reload(settings, script.Reloading)
md = false
end
end, false, Enum.KeyCode.R)
game:GetService("RunService").Heartbeat:Connect(function(dt)
if md then
if canfire and script.Reloading.Value == false then
canfire = false
recoil:shove(Vector3.new(1,math.random(-0.5,0.5),10))
coroutine.wrap(function()
for i,v in pairs(grozamodel.GunComponents.Barrel:GetChildren()) do
if v:IsA("ParticleEmitter") then
v:Emit()
end
end
local firesound = grozamodel.GunComponents.Sounds.Fire:Clone()
firesound.Parent = game.Workspace
firesound:Destroy()
end)()
coroutine.wrap(function()
wait(0.2)
recoil:shove(Vector3.new(-0.3, math.random(-0.3,0.3), -10))
end)()
local castp = RaycastParams.new()
castp.IgnoreWater = true
castp.FilterType = Enum.RaycastFilterType.Blacklist
castp.FilterDescendantsInstances = {viewmodel, game.Players.LocalPlayer.Character}
local mouse = module.getmouse(1000, castp)
module.fire(game.Players.LocalPlayer, mouse, grozamodel.GunComponents.Barrel.Position, settings.vel, settings, game.Players.LocalPlayer.Character)
event:FireServer({
["Function"] = "BulletRep",
["Client"] = game.Players.LocalPlayer,
["Barrel"] = grozamodel.GunComponents.Barrel.Position,
["Mouse"] = mouse,
})
wait(settings.firerate)
canfire = true
elseif script.Reloading.Value == true then
md = false
end
end
end)
event.OnClientEvent:Connect(function(data)
if data["Function"] == "BulletRep" then
if data["Client"] ~= game.Players.LocalPlayer then
module.cast(data["Barrel"], data["Mouse"], 5, nil)
end
end
end)
game.ReplicatedStorage.Event2.Event:Connect(function(data)
if data["Function"] == "Reloadsound" then
reloadsound()
elseif data["Function"] == "Unaim" then
module.aim(false, viewmodel, grozamodel)
end
end)