vovcher
(youareabulgarian)
August 20, 2020, 12:53pm
#1
Practicing metatable right now. and i ran into a problem.
It errors :
15:51:23.202 - Workspace.Script:1: Attempt to modify a readonly table
i already have a table set?
i dont know why it does that could someone help me please
math.random = {}
math.random._index = math.random
val = val or 0
function math.random:newnumber(val)
local self = setmetatable({},math.random)
self(val)
end
math.random:newnumber(100)
1 Like
vovcher
(youareabulgarian)
August 20, 2020, 12:54pm
#2
Im trying to make it so it prints a random number from the value given
sjr04
(uep)
August 20, 2020, 12:54pm
#3
The math
table is readonly. What are you really wanting to do with this?
You could just create simple function to do this. No need for a fancy meta table
wafiud
(wafiud)
August 20, 2020, 1:05pm
#6
I don’t like attach metatables with lua function (example: math.random, math,rad, math.deg).
vovcher
(youareabulgarian)
August 20, 2020, 1:09pm
#7
vovcher:
Practicing metatable
As i said im practicing metatables since i think they’re cool.