I would use raycasts,and a IgnoreList to detect when the projectiles hit
Just print everything the bullets hit from the ignoreList
Viewmodel
Just makes the Cameras CFrame to Viewmodels head CFrame
local humanoid = game.Players.LocalPlayer.CharacterAdded:Wait():WaitForChild("Humanoid");
local viewModel = game.ReplicatedStorage:WaitForChild("viewModel"):Clone();
local function onDied()
viewModel.Parent = nil;
end
local function onUpdate(dt)
viewModel.Head.CFrame = camera.CFrame;
end
humanoid.Died:Connect(onDied);
game:GetService("RunService").RenderStepped:Connect(onUpdate);
Projectiles
Projectiles can be made with raycasts,for a more advanced way you can use this(CFrame Projectiles)
Event.OnClientEvent:Connect(function(Client, StartPos, EndPos)
local Spell = Instance.new("Part")
Spell.Size = Vector3.new(1, 1, 1)
Spell.Anchored = true
Spell.CFrame = CFrame.new(StartPos + Vector3.new(0, 3, 0), EndPos)
Spell.Parent = Client.Character
for i = 1,100 do
local ray = Ray.new(Spell.CFrame.p, (Spell.CFrame.p + Spell.CFrame.LookVector * 1 - Spell.CFrame.p).unit * 2)
local part, position = workspace:FindPartOnRay(ray, Client.Character, false, true)
if part then part:Destroy() Spell:Destroy() return else end
Spell.Position = Spell.Position + Spell.CFrame.LookVector * 1
game:GetService("RunService").Heartbeat:wait()
end
Spell:Destroy()
return
end)
Mag/Shell Drops
Mag is just animations,Via blender or roblox.For roblox the mag must be its on model
Shell Drops
Create the shell, position it where you want it, and add a bodyvelocity,Use DebrisService to clean up everything.
Also for detecting it you could do this
local CameraRay = Ray.new()
local HitPart, HitPosition = ws:FindPartOnRayWithIgnoreList(CameraRay, Ignore)
print(HitPart, HitPosition)
I suppose you know how to make a ray and how to fill out the () by Ray.new
Mark as soltuion