Here is what it looks like: https://gyazo.com/7c2604e9790962deafab38af795bb512
See how there’s just a group of bullets when I aim directly at the muzzle of the gun? It kinda looks like a dot. That’s what I wanna get rid of.
I was thinking of using an ignore list, but would that really work? I need your guys’ help and opinions. Thank you.
SCRIPT:
Server script:
local remote = game.ReplicatedStorage:WaitForChild(“Remotes”):WaitForChild(“GunEvent”)
local cam = game.Workspace.CurrentCamera
remote.OnServerEvent:Connect(function(player, barrelPos, mousePos)
local ray = Ray.new(barrelPos, (mousePos - barrelPos).unit * 50)
local part, position = game.Workspace:FindPartOnRay(ray, player.Character, false, true)
local dist = math.clamp((barrelPos - mousePos).magnitude, 0.05, 50)
if part then
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(7)
end
end
remote:FireAllClients(player, part, position, dist, barrelPos)
end)
Local script:
local remote = game.ReplicatedStorage:WaitForChild(“Remotes”):WaitForChild(“GunEvent”)
local TweenService = game:GetService(“TweenService”)
remote.OnClientEvent:Connect(function(player, part, position, dist, barrelPos)
local bullet = Instance.new("Part")
bullet.Anchored = true
bullet.CanCollide = false
bullet.BrickColor = BrickColor.new("White")
bullet.Name = "bullet"
bullet.Size = Vector3.new(0.075,0.075,dist)
bullet.Transparency = 0.95
bullet.Material = Enum.Material.Neon
bullet.CFrame = CFrame.new(barrelPos, position) * CFrame.new(0,0, -dist/2)
bullet.Parent = game.Workspace
game.Debris:AddItem(bullet, 5)
local Info = TweenInfo.new(
1,
Enum.EasingStyle.Cubic,
Enum.EasingDirection.Out,
0,
false,
0
)
local Goals =
{
Transparency = 1;
}
local tween = TweenService:Create(bullet,Info,Goals)
tween:Play()
end)
I changed the transparency tween longer to make it easier for you guys to see it.