Why isn't my randomizer working?

Hi! I’m the build guy, and I’m trying to make a randomizer with chances. I’m getting the error “Function is not a supported attribute type” on line 18. Should it not be what the function returned? Here are my scripts

AdminChances - ModuleScript
return {
	["Jayknightss"] = 50,
	["NOOB"] = 50,
}
SetStand - Script
local lootTable = require(game.ServerStorage:WaitForChild("AdminChances"))

local Result = function()
	local Sum = 0
	for StandName,Chance in pairs(lootTable) do
		Sum += Chance
	end
	local RandomNumber = math.random(Sum)
	for StandName,Chance in pairs(lootTable) do
		if RandomNumber <= Chance then
			return(StandName)
		else
			RandomNumber -= Chance
		end
	end
end

script.Parent:SetAttribute("Stand",Result)

Extra info: SetStand’s parent is a tool, the attribute is here.


Is the problem by chance that you didn’t call Result?

script.Parent:SetAttribute("Stand", Result())

I’m looking for the return output it gives me, not the function.

"Function is not a supported attribute type”

hey! have you tried to print what result type is? i mean

print(typeof(Result))

Code:

print(Result)

Returned with
function: 0x107acaf429a3550d

I don’t know why it’s not returning with the string.

Oh I see why when you using SetAttribute function, you do not run function. You trying to set attribute value as function.

Your code:
script.Parent:SetAttribute("Stand",Result)
Updated:
script.Parent:SetAttribute("Stand",Result())