This first started with the inability to index my userdata. Basically when I used a ModuleScript to return a customized Userdata I wasn't able to index it.

The script in question

local InsertService = game:GetService("InsertService")
local HttpService = game:GetService("HttpService")

local filesystem = script

local proxy = newproxy(true)

local SourceService = getmetatable(proxy)

SourceService.codingbase = {}

function SourceService:ReplicateToClient(player)
    print("test")
end

--local meta = getmetatable(proxy)
SourceService.__index = SourceService
SourceService.__tostring = function(self)
    return "Source Service"
end
SourceService.__metatable = "The metatable is locked"

proxy:ReplicateToClient()

return proxy

Full script

When requiring this script I wouldn't be able to index the returned Userdata. Causing the error:

attempt to index userdata with 'ReplicateToClient'

After posting that question and playing around with it some more I discovered that when I don't set a metamethod it would still return the prior result.

Say if I commented lines 18-21

--local meta = getmetatable(proxy)
SourceService.__index = SourceService
--SourceService.__tostring = function(self)
    --return "Source Service"
--end
--SourceService.__metatable = "The metatable is locked"

reloaded the script and tried requiring it again

print(require(game.SourceService))

outputs

Source Service

when it should output "userdata: "

or

print(getmetatable(require(game.SourceService)))

outputs

The metatable is locked

when it should output the Userdata's metatable

So I created a fresh script.

local proxy = newproxy(true)

print(proxy)

return proxy

running print(require(userdataTest)) would output

userdata: 0xeefe92ec642d02e3 - Edit - userdataTest > print(require(game.Workspace.userdataTest)) - Studio userdata: 0xeefe92ec642d02e3 - Edit

and sequential calls would output the same.

reloading the script and running it again would result with

userdata: 0xd9eedbd94cba8b63 - Edit - userdataTest > print(require(game.Workspace.userdataTest)) - Studio userdata: 0xeefe92ec642d02e3 - Edit

yes you see that correctly, the initial run done by reloading the script returns a unique hex, but when calling it from the command line it returns the very first Userdata value created by the script.

#Any ideas on whats happening?