hey, so i have a really simple gun but it sometimes interferes with the character or the gun. so im wondering how to make like a “blacklist”. (I am terrible when it comes to ray casting)
remote.OnServerEvent:Connect(function(player, position)
local origin = script.Parent.Handle.Part.Position
local direction = (position - origin).Unit*300
local result = workspace:Raycast(origin, direction)
local intersection = result and result.Position or origin + direction
local distance = (origin - intersection).Magnitude
local bullet_clone = game.ReplicatedStorage.Assets.Bullet:Clone()
bullet_clone.Size = Vector3.new(0.1, 0.1, distance)
bullet_clone.CFrame = CFrame.new(origin, intersection)*CFrame.new(0, 0, -distance/2)
bullet_clone.Parent = workspace
if result then
local part = result.Instance
local humanoid = part.Parent:FindFirstChild("Humanoid") or part.Parent.Parent:FindFirstChild("Humanoid")
if humanoid then
if not character then
humanoid:TakeDamage(10)
end
end
end
for i = 1,10 do
bullet_clone.Transparency += 0.1
wait(0.1)
end
end)