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

Workspace.Tool.Handle.Spoon.Script:7: attempt to perform arithmetic on a string value. What wrong?

while true do
	wait(0)
	if script.Parent.Parent.Parent.Parent:FindFirstChild("Left Arm") then
		local a = script.Parent.Parent.Parent.Parent:FindFirstChild("Left Arm").Position.X
		local b = script.Parent.Parent.Parent.Parent:FindFirstChild("Left Arm").Position.Y
		local c = script.Parent.Parent.Parent.Parent:FindFirstChild("Left Arm").Position.Z + 1
		local d = (a + "," + b + "," + c)
		script.Parent.Parent.Spoon.Position = c
	end
end

and the error is:

> 19:42:02.936 - Workspace.Tool.Handle.Spoon.Script:7: attempt to perform arithmetic on a string value`

1 comment

0

its .. ,not +

1 answer

The problem is:

local c = script.Parent.Parent.Parent.Parent:FindFirstChild("Left Arm").Position.Z + 1 local d = (a + "," + b + "," + c) 

Arithmetic is basically calculation, you don't need to put speechmarks around the commas since its asking for a vector3(i.e numbers not strings.)You treated it as if it was a string.

local c = script.Parent.Parent.Parent.Parent:FindFirstChild("Left Arm").Position.Z + 1 
local d = Vector3.new(a,b,c) 

Is all you need to do; also use the lua button for code blocks.

4 comments

0

Not working

0

20:22:10.278 - Workspace.Tool.Handle.Spoon.Script:7: unexpected symbol near ','

0

local d = Vector3.new(a,b,c) script.Parent.Parent.Spoon.Position = d

0

Don't keep local d and c on the same line its just like that because i took it from your code and lines messed up.

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