Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Help with a material-based bullet hole system with ACS 1.7?

Asked by 9 days ago

Hello, I am currently working on a custom version of ACS 1.7 and I wish to make a material-based bullethole system, I already have the basics of it so, when you shoot, it creates a bullethole on whatever part the bullet hit. Now, what I need is for it to be material-based, so basically, different bulletholes depending on the material of the part that the bullet hit.

The lines for this system to work are:


local default_bulletholes = { "4117124202"; "4117124881"; "4117125609"; "4117126706"; "4117127411"; }

and

    Evt.Hit:FireAllClients(Player, Position, HitPart, Normal, Material, Settings)
            local a = Instance.new("Part", BulletModel)
        a.FormFactor = "Custom"
        a.TopSurface = 0
        a.BottomSurface = 0
        a.Transparency = 1
        a.CanCollide = false
        a.Size = Vector3.new(0.5, 0, 0.5)
        a.CFrame =  CFrame.new(Position,Position-Normal) * CFrame.Angles(90*math.pi/180,math.random(0,360)*math.pi/180,0)
        a.BrickColor = BrickColor.new("Really black")
        a.Material = Enum.Material.Air

        local b = Instance.new('WeldConstraint')
        b.Parent = a
        b.Part0 = a
        b.Part1 = HitPart

        local c = Instance.new("Decal", a)
        c.Texture = "rbxassetid://"..default_bulletholes[math.random(1,5)]
        c.Face = "Top"
--      c.Transparency = 0

        local d = Instance.new("PointLight", a)
        d.Color = Color3.new(0, 0, 0)
        d.Range = 0
        d.Shadows = true

        local e = Instance.new("Weld")
        e.Part0 = a
        e.Part1 = HitPart   

Some help would be extremely appreciated.

My discord: krypto#0514

1 answer

Log in to vote
0
Answered by 9 days ago
Edited 9 days ago

In the default_bulletholes table, name each index the specific Material you want it to be used on.

For example:

local default_bulletholes = {}
default_bulletholes["Enum.Material.Plastic"] = whateverIdYouUseForPlastic

Then on line 19 of the second part, instead of math.random() do tostring(HitPart.Material).

0
This seems like it'd work, haven't tested it yet but I have a question, how would i make it multiple IDs? Just by separating it like: local default_bulletholes = {id1, id2, id3} or: default_bulletholes["Enum.Material.Plastic"] = "ID1", "ID2", "ID3" Cryptographz 0 — 9d
0
Tried doing this and everytime I shot a part it spew this error out: 22:27:21.798 - ServerScriptService.ACS_Server:238: attempt to concatenate string with nil - The script now is c.Texture = "rbxassetid://"..default_bulletholes[tostring(HitPart.Material)] and for the tables it's local default_bulletholes = {} local metal_bulletholes = {} default_bulletholes["Enum.Material.Concrete"] = 4117124881 Cryptographz 0 — 9d
0
local default_bulletholes = {} local metal_bulletholes = {} default_bulletholes["Enum.Material.Concrete"] = 4117124881 metal_bulletholes["Enum.Material.Concrete"] = 5473838721 (Repost because comment length limit) Cryptographz 0 — 9d
0
try using just the actual enum object as the key rather than the whole thing (default_bulletholes[Enum.Material.Concrete] = 4117124881). you would go about indexing this by simply doing "default_bulletholes[Enum.Material.Concrete]" kaytikookie 40 — 8d
Ad

Answer this question