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’m trying to make a glass-like fracture system. What will I use it for? I’m making an attack for a boss that once it punches the ground, it fractures the ground, and stepping on the lines that fracture the ground damages the player.
- What is the issue? Include screenshots / videos if possible!
The
ModuleScript
returns aModel
, but trying to use it errors, as if theInstance
wasnil
.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried, found alot of topics but none of them matched the problem I was having.
ModuleScript code:
local rng = Random.new()
local lightning_part = Instance.new("Part")
lightning_part.Anchored = true
lightning_part.CanCollide = false
lightning_part.Size = Vector3.new(0.25, 0.25, 0.25)
lightning_part.Material = Enum.Material.Neon
lightning_part.Color = Color3.fromRGB(160, 128, 255)
return function(startpos, fractures, thickness, xOffset, yOffset, zOffset)
local points = {}
local model = Instance.new("Model")
for i = 1, fractures do
local offset = Vector3.new(rng:NextNumber(xOffset[1], xOffset[2]), rng:NextNumber(yOffset[1], yOffset[2]), rng:NextNumber(zOffset[1], zOffset[2]))
if i == 1 then
offset = Vector3.new(0, 0, 0)
end
points[#points + 1] = startpos + offset * i
end
for index, point in points do
if points[index + 1] ~= nil then
local beam = lightning_part:Clone()
beam.Size = Vector3.new(thickness, thickness, (points[index] - points[index + 1]).Magnitude)
beam.CFrame = CFrame.new((points[index] + points[index + 1]) / 2, points[index + 1])
beam.Name = "Fracture"..index
beam.Parent = model
end
end
return model
end
What I’m trying to do with the Model
:
local model = require(workspace["Sublevel 90"].Deepbound_Winner.Modules.FractureModule)(workspace.TemplateR6.HumanoidRootPart.Position, 16, 0.25, {0, 15}, {0, 0}, {0, 15})
model.Name = "Fracture"
model.Parent = workspace
Hieraches: (straightforward to the ModuleScript
)
Error message: (I split the console code into lines so it’s not bunched up together)
Things I’m gonna clarify:
The model is not deleted
The TemplateR6 rig DOES exist
Any help is appreciated.