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

When I try to use the SubtractAsync() function, I am given Error Code -21. How can this be fixed?

Asked by 2 years ago

Every time my script activates I am given error code -21 in console. The script does not subtract anything.

the code:

game.ReplicatedStorage.punchg.OnServerEvent:Connect(function(player, rayc, hp)
local part = rayc
local final = rayc:SubtractAsync({hp})
final.Parent = game.Workspace
end)

rayc is the wall, and hp is the part being subtracted from the wall

0
your error code surely can not only be -21. We need the whole red text as this code seems fine. Are you sure your variables (parts) are given correct? Also what are you definging part for? you are not using it. xXMadonXx 190 — 2y
0
Oh and you should definitely put everything async into a pcall!!! xXMadonXx 190 — 2y
0
the line for defining part is useless now. i was using it in an earlier version of the script. also here is everything in developer console (https://ibb.co/0ZyRz0H) C0MMANDING 0 — 2y
0
Are you sure the wall is a BasePart? If yes, try restarting your studio and make sure you’re up-to-date. T3_MasterGamer 2189 — 2y

Answer this question