Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why won't SubtractAsync() CSG Negate?

Asked by 4 years ago
Edited 4 years ago
01game.Players.PlayerAdded:Connect(function(player)
02    local char = player.Character or player.CharacterAdded:Wait()
03    local hitboxClone = game.Workspace.Hitbox:Clone()
04 
05    hitboxClone.Parent = char
06    hitboxClone.Position = char.HumanoidRootPart.Position
07    hitboxClone.Anchored = false
08    hitboxClone.Name = "PlayerHitbox"
09 
10    local weld = Instance.new("Weld",hitboxClone)
11    weld.Part0 = char.HumanoidRootPart
12    weld.Part1 = hitboxClone
13 
14    hitboxClone.Touched:Connect(function(hit)
15        if hit.Name == "Subtract" then
View all 26 lines...

Nothing here throws an error, the clones work, it just won't do the CSG.

0
"The resulting PartOperation is always un-parented and based on positions of the parts as they were when the operation was started." tl;dr parent SubtractUnion to Workspace y3_th 176 — 4y
0
All that does is make the parts clone but not Negate zboi082007 270 — 4y
0
Destroy hitboxClone, too. y3_th 176 — 4y
0
But I need the hitbox clone to exist stay welded on the player zboi082007 270 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Hello. This has a really simple fix.


Problem:

  • You forgot to parent the union to Workspace.

Solution:

  • Parent it to Workspace by using SubtractUnion.Parent = workspace.

Recommendations:

  • Use a WeldConstraint since it doesn't require the "C0" and "C1" properties.

  • Don't use the second argument of Instance.new(). It's inefficient and causes lag. Instead, set it manually by using weld.Parent = hitboxClone.


Fixed Code:

01game.Players.PlayerAdded:Connect(function(player)
02    local char = player.Character or player.CharacterAdded:Wait()
03    local hitboxClone = game.Workspace.Hitbox:Clone()
04 
05    hitboxClone.Parent = char
06    hitboxClone.Position = char.HumanoidRootPart.Position
07    hitboxClone.Anchored = false
08    hitboxClone.Name = "PlayerHitbox"
09 
10    local weld = Instance.new("WeldConstraint")
11    weld.Part0 = char.HumanoidRootPart
12    weld.Part1 = hitboxClone
13    weld.Parent = hitboxClone
14 
15    hitboxClone.Touched:Connect(function(hit)
View all 29 lines...
0
Did that, now it just creates a ton of Clones but no CSG zboi082007 270 — 4y
Ad

Answer this question