Current thread lacking capability RobloxScript

When I try to require a modulescript from a server script in ServerScriptService, I get this strange error I’ve never gotten before:
The current thread cannot read 'UniqueId' (lacking capability RobloxScript)
The name of the modulescript is “UniqueId.”
I’ve already tried moving the modulescript to replicatedstorage, and requiring it from the command bar, but I still got the same error. Yes, the other script is a server script in serverscriptservice. Code:

local Players = game:GetService("Players")
local UniqueId = require(game.ServerScriptService.UniqueId)

Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:SetAttribute("ID", UniqueId:GenerateID())
	end)
end)

UniqueId:TagAllWithTag("GetsID")

The error originates on line two. Thanks for any help you can give!

“UniqueId” is a hidden property of every Instance. The path in your require call is attempting to access this property instead of the child named “UniqueId”. You can either change the name of the ModuleScript or change the access to using FindFirstChild:

local UniqueId = require(game.ServerScriptService:FindFirstChild("UniqueId"))
2 Likes