Hello! I’m currently working on a revolver for my game and I came across this weird bug. When I try to use the gun , it fires the wrong way. I made the bullet transparency 0 so I could see where the bullet is going.
Here is a video: https://youtu.be/12K5qXcAc4A
Server Script:
local ammo = script.Parent.ammo
local module = require(script.Parent.ModuleScript)
ammo.Value = 6
local SHOT_TIME = 1
local noz = Vector3.new(0, 0.4, -1.1)
local SHOT_SPEED = 500
local DebrisService = game:GetService('Debris')
local BaseShot
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player,pos)
if script.Parent.deb.Value == false then
if player.Character:FindFirstChild(script.Parent.Name) then
script.Parent.deb.Value = true
if script.Parent.ammo.Value == 0 then
script.Parent.Handle.ReloadSound:Play()
wait(1)
script.Parent.ammo.Value = 6
script.Parent.deb.Value = false
else
script.Parent.ammo.Value = script.Parent.ammo.Value - 1
local HandleCFrame = script.Parent.Handle.CFrame
local FiringPoint = HandleCFrame.p + HandleCFrame:vectorToWorldSpace(noz)
local ShotCFrame = CFrame.new(FiringPoint, pos)
local LaserShotClone = BaseShot:Clone()
--particle:Clone().Parent = LaserShotClone
LaserShotClone.CFrame = ShotCFrame + (ShotCFrame.lookVector * (BaseShot.Size.Z / 2))
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.velocity = ShotCFrame.lookVector * SHOT_SPEED
BodyVelocity.Parent = LaserShotClone
LaserShotClone.Parent = workspace
game.Debris:AddItem(LaserShotClone,5)
LaserShotClone.Touched:Connect(function(hhh)
if hhh.Parent:FindFirstChild("Humanoid") then
print('found hum')
if hhh.Parent.Humanoid.Health == 0 then print('already dead') return end
local plr = game.Players:GetPlayerFromCharacter(hhh.Parent)
if (plr) then
if plr.Name == player.Name then print('localplayer') else
if hhh.Parent:FindFirstChild("creator") then
hhh.Parent.creator:Destroy()
end
hhh.Parent.Humanoid:TakeDamage(67)
local tag = Instance.new('StringValue',hhh.Parent.Humanoid)
tag.Value = player.Name
tag.Name = "creator"
game.Debris:AddItem(tag,0.5)
LaserShotClone:Destroy()
end
else
print('isnt a player')
end
end
end)
script.Parent.Handle.FireSound:Play()
script.Parent.Handle.Main.l.Enabled = true
script.Parent.Handle.Main.p:Emit(10)
wait(0.05)
script.Parent.Handle.Main.l.Enabled = false
wait(0.25)
script.Parent.deb.Value = false
end
end
end
end)
BaseShot = Instance.new('Part')
BaseShot.CanCollide = false
BaseShot.Anchored = false
BaseShot.Transparency = 0
BaseShot.Size = Vector3.new(1,1,1)