So, basically my issue that I am dealing with is that once my Hitbox Module gets fired, it’ll contionusly set the Hitbox’s parent to Folder, although it’s already set? I haven’t really tried any methods because I really don’t know any methods that would solve this off the top of my head right now. The error is the question is,
The Parent property of Hitbox is locked, current parent: NULL, new parent Player2Misc. Hitbox
The script in question though is different, being this (
local HB = script.Hitbox:Clone()
local Players = game:GetService("Players")
local Debris = game:GetService("Debris")
local RS = game:GetService("ReplicatedStorage")
local MM = require(RS.Modules.MainModule)
local HitboxModule = {}
function HitboxModule.Detection(Character, ToolName, HitboxData, Par, Timing)
local Player = Players:GetPlayerFromCharacter(Character)
local HumRP = Character:FindFirstChild("HumanoidRootPart")
local Folder = Instance.new("Folder")
Folder.Name = Player.Name.. "Misc. Hitbox"
Folder.Parent = Par
Debris:AddItem(Folder, Timing)
HB.Size = HitboxData
HB.Parent = Folder
HB.CFrame = HumRP.CFrame * CFrame.new(0, 0, -2)
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = HB
Weld.Part1 = HumRP
Weld.Parent = Weld.Part0
local Whitelist = OverlapParams.new()
Whitelist.FilterType = Enum.RaycastFilterType.Whitelist
Whitelist.FilterDescendantsInstances = {workspace.PlayerHitboxes}
if ToolName == "Katana" then
HB.Size = Vector3.new(3.8, 0.8, 1.2)
HB.CFrame = ToolName.CFrame
end
local Detection = workspace:GetPartBoundsInBox(HB.CFrame, HB.Size, Whitelist)
Debris:AddItem(HB, Timing)
for _, PlayerGettingHit in pairs(Detection) do
if PlayerGettingHit and PlayerGettingHit:FindFirstChildOfClass("ObjectValue") and PlayerGettingHit.Char.Value ~= Character then
local eChar = PlayerGettingHit.Char.Value
local enemyHum = eChar.Humanoid
if enemyHum then
if enemyHum.Health > 0 then
return eChar, enemyHum
end
end
end
end
end
return HitboxModule
The issue isn’t related to the paraments at all, it’s on the line which is,
HB.Parent = Folder