Hi,
As you may know, you can’t change the size of a part’s hitbox.
I’ve been trying to increase the size of unanchored parts’ hitboxes, by making an invisible part and doing stuff with it,so players just don’t walk over them - instead they actually push the object, like other games.
Please take this post for reference: How can i optimize this?
I have tried so many things, but either my studio outright crashes - or if i run my game through the roblox client nothing loads, and my camera is completely frozen.
Please help, thank you.
add a part inside the unanchored part which will be the hitbox, weld the unanchored and hitbox part together.
Weld the hitbox to the unanchored part.
I am doing exactly that, but the problem here lies with CollectionService, here is my code:
workspace.DescendantAdded:Connect(function(descendant)
if descendant:IsA("BasePart") and descendant.Anchored == false and not descendant:IsA("FileMesh") then
CollectionService:AddTag(descendant, "Unanchored")
end
end)
for _, part in workspace:GetDescendants() do
if part:IsA("BasePart") and part.Anchored == false and not part:IsA("FileMesh") then
CollectionService:AddTag(part, "Unanchored")
local BoundingBox = Instance.new("Part")
BoundingBox.Name = DEFAULT_BOUNDINGBOX_NAME
BoundingBox.Size = part.Size * 1.3
BoundingBox.Transparency = 1
BoundingBox.CFrame = part.CFrame
BoundingBox.Massless = true
BoundingBox.Parent = part
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = part
Weld.Part1 = BoundingBox
Weld.Parent = BoundingBox
part.CanCollide = false
table.insert(BoundingBoxes, BoundingBox)
end
end
CollectionService:GetInstanceAddedSignal("Unanchored"):Connect(function()
local UnanchoredParts = CollectionService:GetTagged("Unanchored")
for _, part in UnanchoredParts do
if part:FindFirstChild(DEFAULT_BOUNDINGBOX_NAME) then
continue
else
local BoundingBox = Instance.new("Part")
BoundingBox.Name = DEFAULT_BOUNDINGBOX_NAME
BoundingBox.Size = part.Size * 1.3
BoundingBox.Transparency = 1
BoundingBox.CFrame = part.CFrame
BoundingBox.Massless = true
BoundingBox.Parent = part
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = part
Weld.Part1 = BoundingBox
Weld.Parent = BoundingBox
part.CanCollide = false
table.insert(BoundingBoxes, BoundingBox)
end
end
end)
This code crashes studio, and i have no idea why.
nevermind it was a simple check
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.