I am trying to get some values, which works, make them a string and put them into a table, however this is not working:
function Move(Unit) local PositionX = tonumber(Unit.Location.Value:sub(1,1)) print (PositionX) local PositionZ = tonumber(Unit.Location.Value:sub(3,3)) local Adjacent = {} local Position1 = string(PositionX..","..(tonumber(PositionZ) +1)) local Position2 = string(PositionX..","..tonumber(PositionZ) -1) local Position3 = string(tonumber(PositionX) +1 ..","..PositionZ) local Position4 = string(tonumber(PositionX) -1 ..","..PositionZ) table.insert(Adjacent, Position1) table.insert(Adjacent, Position2) table.insert(Adjacent, Position3) table.insert(Adjacent, Position4) for i=1, 4 do game.Workspace.Plates[Adjacent[i]].Material = "Neon" end end
Error: 14:56:08.739 - Workspace.Script:6: attempt to call global 'string' (a table value)
tonumber
takes a numerical string and converts it into a number type. Similarly, tostring
converts things into a string.
string
is actually a library, so it thinks you're doing something with that. Write tostring
instead.
You can't just make up a function an expect it to work.
To convert something into a string, use tostring. It receives an argument of any type and literally converts it to string format.
local str = tostring(5) print(type(str)) --> string