I'm messing around trying to create a humanoid, and I can't seem to change the values in the userdata created with newproxy.
local HumanoidObjects = {
Health = 100; -- By default
HealthRegenRate = 1 -- Per second
};
function CreateHumanoid(Player)
local Hum = newproxy(true);
local Data = getmetatable(Hum);
Data.__index = HumanoidObjects;
return Hum;
end
--[[ ]]
local Player = game.Players.LocalPlayer;
local Humanoid = CreateHumanoid(Player);
print(Humanoid.Health); -- Prints 100
Humanoid.Health = 10; -- Gives an error saying "attempt to index local 'Humanoid' (a userdata value)"
The error is attempt to index local 'Humanoid' (a userdata value)
It's probably a stupid mistake I made myself and i'm probably not noticing it.
Any help would be appreciated, thanks!

1 comment
Thanks! Tt worked, and i'll keep that in mind.