You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make my shotgun better by having the spread increase and decrease based on how far the player is from the target, and I also want stray bullets to still land on enemies even the cursor isn’t directly on them. -
What is the issue? Include screenshots / videos if possible!
I honestly can’t figure out how to add those features to my system -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve already tried looking through the dev forums and tutorials but haven’t found anything. This could be on me though since I haven’t had the chance to look for super long.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
This is my code currently for the shotgun.
for pellet = 1, PELLETS do
local instance
local spreadX = HORIZONTAL_SPREAD.min + (math.random() * (HORIZONTAL_SPREAD.max - HORIZONTAL_SPREAD.min))
local spreadY = VERTICAL_SPREAD.min + (math.random() * (VERTICAL_SPREAD.max - VERTICAL_SPREAD.min))
result = workspace:Raycast(OGPos, ((mouseHit - OGPos) + Vector3.new(spreadX, spreadY)) * MaxDist, rayParams)
if result then
instance = result.Instance
print(instance.Name)
local model = instance:FindFirstAncestorOfClass("Model")
if model then
if model:FindFirstChild("Humanoid") then
if model.Humanoid.Health > 0 then
if instance:GetAttribute("WeakPoint") then
local multiplier = instance:GetAttribute("WeakPoint")
model.Humanoid:TakeDamage(dmg * multiplier)
print(dmg * multiplier)
else
model.Humanoid:TakeDamage(dmg)
print(dmg)
end
end
else
addHole(result)
end
elseif instance.Name == "BulletHole" then
addHole(result)
elseif not model then
addHole(result)
end
end
end
end
end)