Here is the code for the tracer;
function CreatePartOnPosition(position)
local part = Instance.new("Part", workspace.Hits)
part.CanCollide = false
part.Anchored = true
part.Position = position
part.Size = Vector3.new(0.05,0.05,0.05)
part.Transparency = .4
local attachment = Instance.new("Attachment", part)
return part
end
function CreateBeam(position, gunMuzzle, guntipPos, speed)
local gunTip = gunMuzzle:Clone()
gunTip.Size = Vector3.new(0.05,0.05,0.05)
gunTip.Parent = workspace.Hits
gunTip.Transparency = 1
local connectAttachment = CreatePartOnPosition(position)
local beam = game.ReplicatedStorage.Beam:Clone()
beam.Parent = workspace.Hits
beam.Attachment0 = gunTip.FrontBarrel
beam.Attachment1 = connectAttachment.Attachment
local calculateTimeOfShot = (position-guntipPos).magnitude / speed
local tweenInfo = TweenInfo.new(calculateTimeOfShot, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local partProperties = {Position = position}
local tween = tweenService:Create(gunTip, tweenInfo, partProperties)
tween:Play()
tween.Completed:connect(function()
gunTip:Destroy()
connectAttachment:Destroy()
beam:Destroy()
end)
end
Here is the area where position is determent
local hit,position = workspace:FindPartOnRayWithIgnoreList(extendedRay, {workspace.Hits, gunTip.Parent.FireLeft})
CreateBeam(position, gunTip,Direction, speed)
That is server side of the code, now to answer the question @REALTimothy0812 had
The client invokes the server with this;
local mousepos = mouse.Hit
fireGun:InvokeServer("Gun Name", gun, fireCount, mousepos)
If theres anything else you need to help me towards a solution, let me know. All help is much appreciated.