What i mean by gun spread is that weapons that have more spread accuracy the more you shoot it.
Currently mine uses TweenService and a NumberValue. This function gets the current spread and also increases it, whilst playing a TweenTrack to decrease it back to it’s minimum accuracy at a set velocity.
local function GetSpread()
local min, max = Settings.MinimumAccuracy or 0, Settings.MaximumAccuracy or 0
if not Settings.SpreadFactor or Settings.SpreadFactor <= 0 then
return min, max -- If weapon is not intended to have spread, then return it's raw accuracy values
end
local dif = math.abs(max - min)
max = SpreadValue.Value
SpreadValue.Value += dif * Settings.SpreadFactor
if SpreadValue.Value > Settings.MaximumAccuracy or 0 then
SpreadValue.Value = Settings.MaximumAccuracy or 0
end
local dif = SpreadValue.Value - Settings.MinimumAccuracy
local speed = (Settings.MaximumAccuracy - Settings.MinimumAccuracy) * Settings.SpreadRecovery
local tweentime = dif / speed
local tweeninfo = TweenInfo.new(tweentime, Enum.EasingStyle.Linear)
local Track = TweenService:Create(SpreadValue, tweeninfo, {Value = Settings.MinimumAccuracy or 0})
Track:Play()
return min, max
end
I’m wondering if this is good for full-auto weapons that shoot every 0.05 seconds, since TweenTracks are being created and played very rapidly. Feedback would be appreciated.