SubtractAsync not working

Hello, I was trying to make a chopping system and I had planned to use SubtractAsync to make dents in the object you’re chopping. I used a local script to detect when you click and then fire a remote event which would indent the object you’re chopping. I was getting an error and did some experimenting. I found that it works only when I don’t use a remote event. I’m very confused, if anyone could help, that would be appreciated.

May I see your scripts? There’s nothing I can base my answer on

1 Like

localscript:

local char = player.Character
local hum = char:FindFirstChild("Humanoid")
local userInputService = game:GetService("UserInputService")
local mouse = player:GetMouse()
userInputService.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		local raycast = workspace:Raycast(workspace.CurrentCamera.CFrame.Position, mouse.UnitRay.Direction * 100)
		if raycast then
			print(raycast)
			
			game.ReplicatedStorage.Remotes.BreakObjectServer:FireServer(raycast.Position, raycast.Instance)
		end
		

	end
end)

serverscript:

game.ReplicatedStorage.Remotes.BreakObjectServer.OnServerEvent:Connect(function(player,pos,part)
	local subtrahend = Instance.new("NegateOperation")
	subtrahend.Size = Vector3.new(1,1,1)
	subtrahend.Position = pos
	subtrahend.Parent = game.Workspace
	local union = part:UnionAsync({subtrahend})
	union.Parent = game.Workspace	
end)

the remote is probably mispelled in the explorer or in the script

Try adding a WaitForChild on a remoteevent

local player = game.Players.LocalPlayer
local char = player.Character
local hum = char:FindFirstChild("Humanoid")
local rs = game:GetService("ReplicatedStorage")
local remotes = rs:WaitForChild("Remotes")
local bos = remotes:WaitForChild("BreakObjectServer")
local mouse = player:GetMouse()

mouse.Button1Down:Connect(function()
	local raycast = workspace:Raycast(workspace.CurrentCamera.CFrame.Position, mouse.UnitRay.Direction * 100)
	if raycast then
		bos:FireServer(raycast.Position, raycast.Instance)
	end
end)
local rs = game:GetService("ReplicatedStorage")
local remotes = rs:WaitForChild("Remotes")
local bos = remotes:WaitForChild("BreakObjectServer")

bos.OnServerEvent:Connect(function(player, pos, part)
	local subtrahend = Instance.new("NegateOperation")
	subtrahend.Size = Vector3.new(1, 1, 1)
	subtrahend.Position = pos
	subtrahend.Parent = workspace
	local union = part:UnionAsync({subtrahend})
	union.Parent = workspace
end)

Everything else looks fine on my end. I just added a few waits, changed the input collection slightly & defined player in the local script.

It was a csg error, not an error with a remote event. It could print hi on the server script.