Possible way to look for a property via varible

Hello! I am trying to make a function where the game loads different lighting via a module script in a map, but my issue is that there doesn’t seem to a clear cut way to do this (that i know of)

I am willing to:

  • Check the dictionary key (which looks like module.whatever property) and set it to the value
module.Brightness = 3

or run through every property in the lighting, and check if it has a place in the module and set it if it does.

My function looks like this for now

function loadLighting(map)
	local lightingmodule = require(map:FindFirstChild("mapLighting"))
	if lightingmodule then
		for i,v in lightingmodule do
			-- Do whatever here
		end
	end
end

Like always, any help is very useful and thank you for reading!

I’m not entirely certain I understand exactly what it is you want to do.

But

for i,v in lightingmodule do
	-- Do whatever here
        game.Lighting[i] = v
end

Would that technically do what you wish to accomplish? It will of course error if the property name doesn’t exist in lighting, but you could throw it in a pcall or design your module to have a module.Properties thing if it holds more than just valid lighting properties.

I mean, it does something??
not really what it needs to do but progress?

What properties are you trying to set? Can you list them and the values you are trying to set them to?

It’s currently just two simple properties of Ambient and Brightness.

they are already set default .

but when level changes happen the require different. lighting if you get me

local module = {}

module.Ambient = Color3.new(70,70,70)
module.Brightness = 1

return module

Ahh. Yeah, color3.new wants a percentage 0,1. (so you’re setting it to 7000% on accident)

Try doing Color3.fromRGB() instead

I keep forgetting about RGB and all that funky color3 stuff lol

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.