Hello, this is the script. Thanks for helping!
-
VARIABLES << –
RemotesFolder = game.ReplicatedStorage.GameInteractions.GunRemotes
DamageRE = RemotesFolder:WaitForChild(“DamageRE”)
ShootRE = RemotesFolder:WaitForChild(“ShootRE”)
HitRE = RemotesFolder:WaitForChild(“HitRE”)
UpdateAmmoRE = RemotesFolder:WaitForChild(“UpdateAmmoRE”)
ReloadRE = RemotesFolder:WaitForChild(“ReloadRE”)
FakeArms = RemotesFolder:WaitForChild(“FakeArms”)
FakeArmsRemove = RemotesFolder:WaitForChild(“FakeArmsRemove”)
local function TasePlayer(Character)
local Descendants = Character:GetDescendants()
for i=1, #Descendants do
local CurrentDescendant = Descendants[i]
if CurrentDescendant:IsA(“Motor6D”) then
local socket = Instance.new(“BallSocketConstraint”)
local part0 = CurrentDescendant.Part0
local joint_name = CurrentDescendant.Name
local attachment0 = CurrentDescendant.Parent:FindFirstChild(joint_name…“Attachment”) or CurrentDescendant.Parent:FindFirstChild(joint_name…“RigAttachment”)
local attachment1 = part0:FindFirstChild(joint_name…“Attachment”) or part0:FindFirstChild(joint_name…“RigAttachment”)
if attachment0 and attachment1 then
socket.Attachment0, socket.Attachment1 = attachment0, attachment1
socket.Parent = CurrentDescendant.Parent
CurrentDescendant:Destroy()
end
end
end
end
local function GetHitSurfaceCFrame(Hit, Pos)
if Hit and Hit.CFrame then
local SurfaceCF = {
{“Back”, Hit.CFrame * CFrame.new(0,0,Hit.Size.z)};
{“Bottom”,Hit.CFrame * CFrame.new(0,-Hit.Size.y,0)};
{“Front”,Hit.CFrame * CFrame.new(0,0,-Hit.Size.z)};
{“Left”,Hit.CFrame * CFrame.new(-Hit.Size.x,0,0)};
{“Right”,Hit.CFrame * CFrame.new(Hit.Size.x,0,0)};
{“Top”,Hit.CFrame * CFrame.new(0,Hit.Size.y,0)}
}
local ClosestDist = math.huge
local ClosestSurface = nil
for _,v in pairs(SurfaceCF) do
local SurfaceDist = (Pos - v[2].p).magnitude
if SurfaceDist < ClosestDist then
ClosestDist = SurfaceDist
ClosestSurface = v
end
end
return ClosestSurface[2]
end
end
DamageRE.OnServerEvent:Connect(function(Player, Target, Damage, GunSettings, Gun)
if Target then
if Target.Humanoid.Health > 0 and GunSettings.GunType ~= “Taser” then
Target.Humanoid:TakeDamage(Damage)
elseif Target.Humanoid.Health > 0 and GunSettings.GunType == “Taser” then
delay(0, function()
if game.Players:GetPlayerFromCharacter(Target) then
DamageRE:FireClient(game.Players:GetPlayerFromCharacter(Target), false)
end
Target.Humanoid.PlatformStand = true
local Attachment01 = Instance.new("Attachment", Gun.Main)
local Attachment02 = Instance.new("Attachment", Target:FindFirstChild("Torso"))
local Barbs01 = Instance.new("Beam", Gun:FindFirstChild("Main"))
Barbs01.Attachment0 = Attachment01
Barbs01.Attachment1 = Attachment02
Barbs01.Width0 = 0.01
Barbs01.Width1 = 0.01
Barbs01.ZOffset = 0.3
Barbs01.FaceCamera = true
Barbs01.Transparency = NumberSequence.new(0)
local Barbs02 = Instance.new("Beam", Gun:FindFirstChild("Main"))
Barbs02.Attachment0 = Attachment01
Barbs02.Attachment1 = Attachment02
Barbs02.Width0 = 0.01
Barbs02.Width1 = 0.01
Barbs02.ZOffset = -0.3
Barbs02.FaceCamera = true
Barbs02.Transparency = NumberSequence.new(0)
local DeploySound = Instance.new("Sound", Target:FindFirstChild("Torso"))
DeploySound.SoundId = "rbxassetid://277635663"
DeploySound:Play()
TasePlayer(Target)
DeploySound.Ended:Wait()
Target.Humanoid.PlatformStand = false
Attachment01:Destroy()
Attachment02:Destroy()
Barbs01:Destroy()
Barbs02:Destroy()
if game.Players:GetPlayerFromCharacter(Target) then
DamageRE:FireClient(game.Players:GetPlayerFromCharacter(Target), true)
end
end)
end
end
end)
ShootRE.OnServerEvent:Connect(function(Player, Gun, Settings)
Gun.GunValues.CurrentAmmo.Value = Gun.GunValues.CurrentAmmo.Value - 1
ShootRE:FireAllClients(Player, Gun, Settings)
end)
HitRE.OnServerEvent:Connect(function(Player, Hit, Pos)
if Hit and Hit.CFrame and Hit.Name ~= “Glass” and Hit.Name ~= “RightWheel” and Hit.Name ~= “LeftWheel” and Hit.Name ~= “Wheel” and Hit.Name ~= “Non-powered wheel” then
local SurfaceCF = GetHitSurfaceCFrame(Hit, Pos)
local SurfaceDir = CFrame.new(Hit.CFrame.p, SurfaceCF.p)
local SurfaceDist = SurfaceDir.lookVector * (Hit.CFrame.p - SurfaceCF.p).magnitude / 2
local SurfaceOffset = Pos - SurfaceCF.p + SurfaceDist
local SurfaceCFrame = SurfaceDir + SurfaceDist + SurfaceOffset
local Hit_Part = Instance.new(‘Part’, workspace)
Hit_Part.Size = Vector3.new(1, 1, 0.2)
Hit_Part.Shape = Enum.PartType.Block
Hit_Part.CanCollide = false
Hit_Part.CFrame = SurfaceCFrame
Hit_Part.Anchored = true
Hit_Part.Transparency = 1
local HitParticle = script.ParticleEmitter:Clone()
HitParticle.Parent = Hit_Part
game:GetService(“Debris”):AddItem(Hit_Part, 1)
else
if Hit and Hit.Name == “RightWheel” or Hit.Name == “LeftWheel” or Hit.Name == “Wheel” or Hit.Name == “Non-powered wheel” then
Hit.CanCollide = false
local TirePopSound = Instance.new("Sound", Hit)
TirePopSound.Name = "PopSound"
TirePopSound.PlaybackSpeed = 3
TirePopSound.SoundId = "rbxassetid://151284431"
TirePopSound:Play()
game:GetService("Debris"):AddItem(TirePopSound, TirePopSound.TimeLength + 2)
else
if Hit and Hit.Name == “Glass” then
Hit.Transparency = 1
Hit.CanCollide = false
local WindowSmashSound = Instance.new("Sound", Hit)
WindowSmashSound.Name = "SmashSound"
WindowSmashSound.PlaybackSpeed = 1
WindowSmashSound.SoundId = "rbxassetid://156444949"
WindowSmashSound:Play()
game:GetService("Debris"):AddItem(WindowSmashSound, WindowSmashSound.TimeLength + 2)
delay(30, function()
if Hit and Hit.Name == "Glass" then
Hit.Transparency = 0
Hit.CanCollide = true
end
end)
end
end
end
end)
ReloadRE.OnServerEvent:Connect(function(Player, Gun, GunSettings, Equipped)
if Equipped then
wait(GunSettings.ReloadTime)
if (Gun.GunValues.StoredAmmo.Value - (GunSettings.LoadedAmmo - Gun.GunValues.CurrentAmmo.Value)) <= 0 then
Gun.GunValues.CurrentAmmo.Value = Gun.GunValues.CurrentAmmo.Value + Gun.GunValues.StoredAmmo.Value
Gun.GunValues.StoredAmmo.Value = 0
else
Gun.GunValues.StoredAmmo.Value = Gun.GunValues.StoredAmmo.Value - (GunSettings.LoadedAmmo - Gun.GunValues.CurrentAmmo.Value)
Gun.GunValues.CurrentAmmo.Value = GunSettings.LoadedAmmo
end
ReloadRE:FireClient(Player)
end
end)
UpdateAmmoRE.OnServerEvent:Connect(function(Player)
UpdateAmmoRE:FireClient(Player)
end)
FakeArms.OnServerEvent:Connect(function(Player, LeftPos, RightPos)
if Player.Character then
Player.Character.Torso[“Right Shoulder”].Part1 = nil
Player.Character.Torso[“Left Shoulder”].Part1 = nil
local Left_Weld = Instance.new(“Weld”, Player.Character.Torso)
Left_Weld.Name = “Left_Weld”
Left_Weld.Part0 = Player.Character.Head
Left_Weld.C0 = CFrame.new(0, -1.5, 0)
Left_Weld.Part1 = Player.Character[“Left Arm”]
Left_Weld.C1 = LeftPos
local Right_Weld = Instance.new(“Weld”, Player.Character.Torso)
Right_Weld.Name = “Right_Weld”
Right_Weld.Part0 = Player.Character.Head
Right_Weld.Part1 = Player.Character[“Right Arm”]
Right_Weld.C0 = CFrame.new(0, -1.5, 0)
Right_Weld.C1 = RightPos
end
end)
FakeArmsRemove.OnServerEvent:Connect(function(Player)
if Player.Character then
local Torso = Player.Character.Torso
Torso[“Right Shoulder”].Part1 = Player.Character[“Right Arm”]
Torso[“Left Shoulder”].Part1 = Player.Character[“Left Arm”]
if Torso:FindFirstChild(“Left_Weld”) then Torso:FindFirstChild(“Left_Weld”):Destroy() end
if Torso:FindFirstChild(“Right_Weld”) then Torso:FindFirstChild(“Right_Weld”):Destroy() end
if workspace.FakeArms:FindFirstChild(Player.Name) then workspace.FakeArms:FindFirstChild(Player.Name):Destroy() end
end
end)