Basically, I want to create a "Square shaped" hole in the ground, but this error prevents me from doing so.
Here's the code:
Server
remote.OnServerEvent:Connect(function(player,data)
if data and data["P"] then
if data.P == "CreatePunjiTrap" then
local d = data
local newpart = Instance.new('Part')
newpart.Parent = workspace
newpart.Anchored = true
newpart.Position = d["Pos"]
newpart.Size = Vector3.new(10,5,10)
local oof = {}
table.insert(oof,d["Part"])
local new = d["Part"]:SubtractAsync(d["Part"])
d["Part"]:Destroy()
newpart:Destroy()
new.Parent = workspace
end
end
end)
local script:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local remote = game.ReplicatedStorage.MasterRemote
mouse.Button1Down:Connect(function()
remote:FireServer({["P"]="CreatePunjiTrap",["Pos"]=mouse.hit.p,["Part"]=mouse.Target})
end)

2 comments
SubtractAsync takes an array as an argument, so wrap your part(s) in curly braces {d["Part"]}
@incapaz that works, but now I got a new error, attempt to index local 'new' (a nil value)