Hello, I have no clue why is this not working, it should work, but it doesn’t…
function module.GetPointTime(Player,NumberPoint)
local PlayerData = module.CheckIfPlayerExistsInTable(Player)
print(NumberPoint,PlayerData)
if (PlayerData.Points[NumberPoint]) then
print("Found player at getpointtime")
print(os.clock() - PlayerData.Points[NumberPoint])
print(PlayerData.Points[NumberPoint])
return os.clock() - PlayerData.Points[NumberPoint]
end
return 0
end
Here’s a function i’m using to get a value from a position in “Points” at PlayerData…
The thing is:
When I print
print(NumberPoint,PlayerData)
It works perfect!
And numberpoint is clearly on PlayerData.Points, though, it doesn’t returns anything
Output:
It seems to be stuck on the if statement meaning it never found the Index make sure NumberPoint isn’t a string or if it is you can do if PlayerData.Points[tonumber(NumberPoint)] then
function module.GetPointTime(Player,NumberPoint)
local PlayerData = module.CheckIfPlayerExistsInTable(Player)
print(NumberPoint,PlayerData)
if (PlayerData[NumberPoint]) then
print("Found player at getpointtime")
print(os.clock() - PlayerData.Points[NumberPoint])
print(PlayerData.Points[NumberPoint])
return os.clock() - PlayerData.Points[NumberPoint]
end
return 0
end
Don’t know what you mean
I’ll show more of the code;
local module = {}
function module.CheckIfPlayerExistsInTable(p)
if (module[p]) then
return module[p]
end
return {Points = {},LastKey = ''}
end
function module.StorePointAndTick(Player,startpoint)
if not (StarterPoint) then
StarterPoint = startpoint
end
local PlayerData = module.CheckIfPlayerExistsInTable(Player)
local PointKey = StarterPoint + 1
StarterPoint += 1
if (PlayerData.Points[PointKey]) then
print("Found",PointKey,"Return :D")
return; -- Makes sure we don't duplicate pointkey
end
PlayerData.Points[PointKey] = os.clock()
PlayerData.LastKey = PointKey
print("Add",PointKey)
module[Player] = PlayerData
end
function module.UntickLastPoint(Player)
local PlayerData = module.CheckIfPlayerExistsInTable()
local PointK = PlayerData.LastKey
if (PointK) then
if (PlayerData.Points[PointK]) then
PlayerData.Points[PointK] = os.clock() - PlayerData.Points[PointK]
--print("Unticking")
end
end
end
function module.GetPointTime(Player,NumberPoint)
local PlayerData = module.CheckIfPlayerExistsInTable(Player)
NumberPoint = NumberPoint and tonumber(NumberPoint)
print(NumberPoint,PlayerData)
if (PlayerData.Points[NumberPoint]) then
print("Found player at getpointtime")
print(os.clock() - PlayerData.Points[NumberPoint])
return os.clock() - PlayerData.Points[NumberPoint]
end
return 0
end
return module
Can you clearify what part of it don’t you know what I mean?
Does NumberPoint equal to the 5 key in the Points table (from floating point perspective)? It’ll only index if they rawequal to each other. (Test it via next or pairs)
So what do you expect me to do?
It won’t return the value, and I don’t know why,
local a = {
[1] = ‘hi’
}
local b = a[1]
print(b)
This is literally what I’m doing
And what do you mean with “floating point perspective”??