Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Workspace.Anonymous.Script:20: attempt to perform arithmetic (sub) on Instance?

Uhhhh, so i got this unexpected error, andddd yep.

for _, v in pairs(game.Workspace:GetChildren()) do
		if v.Name ~= "Anonymous" and v:FindFirstChild("Humanoid") ~= nil and CheckDist(v.HumanoidRootPart - script.Parent.Torso) <= 70 then
			target = v

3 comments

0

change CheckDist(v.HumanoidRootPart - script.Parent.Torso) <= 70 to (v.HumanoidRootPart.Position - script.Parent.Torso.Position).Magnitude <= 70

0

The error is something to do with your function, which I'm not sure what your function is doing. But your parameter is subtracting a HumanoidRootPart from a Torso, not the position.

0

It's not the checkdist function, It's the Humanoid part.

1 answer

dude, it's because your trying to subtract a torso and humanoid rootpart, these are objects/instances

This discussion is preserved as it was. New answers, comments, and votes are closed.