As the title says, I’m trying to find out a way to represent my gun’s spread through the size of a frame onscreen…
This is the part that changes the spread circle change
local function UpdateSpreadRing()
local FinalAccuarcy = Character.Instability.Value + GunInfo.BaseAccuarcy.Value
if FinalAccuarcy > GunInfo.MaxSpread.Value then
FinalAccuarcy = GunInfo.MaxSpread.Value
end
Cursor.ImageLabel.ImageLabel:TweenSize(UDim2.new(0,math.ceil(FinalAccuarcy*45),0,math.ceil(FinalAccuarcy*45)),Enum.EasingDirection.Out,Enum.EasingStyle.Back,.1,true)
end
Its not exactly that accurate. And this is the part where I make the bullet rays…
local mouseDirection = (Mouse.Hit.Position - Gun.Attachment.WorldPosition).Unit
local FinalAccuarcy = Character.Instability.Value + GunInfo.BaseAccuarcy.Value
if FinalAccuarcy > GunInfo.MaxSpread.Value then
FinalAccuarcy = GunInfo.MaxSpread.Value
end
local directionalCF = CFrame.new(Vector3.new(), mouseDirection)
RNG = Random.new()
local direction = (directionalCF * CFrame.fromOrientation(0, 0, RNG:NextNumber(0, TAU)) * CFrame.fromOrientation(math.rad(RNG:NextNumber(0, FinalAccuarcy)), 0, 0)).LookVector
direction = direction * GunInfo.ShotType.MaxDist.Value
local Origin = Gun.Attachment.WorldPosition
local Raycast = workspace:Raycast(Gun.Attachment.WorldPosition, direction, raycastParams)