Ex string wtih visible

im giving a property in my frame called “visible” a bool value, and it says its a string.

local Value = nil
	
	if ValType == "Bool" then
		if Val == "true" then
			Value = true
		elseif Val == "false" then
			Value = false
		else
			Menu.ReturnCode("A7")
		end
	end
	
	print(Value)
	
	Obj[Prop] = Value

Obj is an object, prop is visible, ValType is “Bool” and Val is “true”

this should convert my string into a bool, and it does
heres it printing the converted bool:
image

so idk why it still ays its a string

I am quite confused by the code you gave. What is “ValType”, what is “Val”, what does Menu.ReturnCode(“A7”) do? You also conveniently cut out the actual error message lol.

oh wait nvm uh

Still, could you show the actual error message?

error message jsut says "attempt to index string with “visible”

Heres all of the function

local function Tog(Path, Prop, Val, ValType)
	local Div = string.split(Path, ".")
	
	
	local function getInstance<T>(instance: Instance, ...: string): T
		for _, childName in ipairs({ ... }) do
			local child = instance:FindFirstChild(childName)
			assert(child, string.format("%s is not a child of %s", childName, instance:GetFullName()))
			instance = child
		end

		-- We want this function to be callable with generic types
		return (instance :: any) :: T
	end
	
	
	local Obj = getInstance(Path)
	
	local Value = nil
	
	if ValType == "Bool" then
		if Val == "true" then
			Value = true
		elseif Val == "false" then
			Value = false
		else
			Menu.ReturnCode("A7")
		end
	end
	
	print(Value)
	
	Obj[Prop] = Value
end

(this is that “tog” functino i was talking about in the other post)

Obj is a string then

it has nothing to do with Value

o, obj is ran through that script the other guy made me to turn it into an object… right?

It should, but it seems like it currently isn’t. Could you gimme the path and also try printing Obj?

also gtg afk rq

theres a lot of the script i forgot to add, but i dont understand how it works at all

Putting it all together:

local function getParentInstanceFromPath(splitPathNames)
	if splitPathNames[1] == "game" then
		table.remove(splitPathNames, 1)
	end

	local success, service = pcall(function()
		-- GetService("workspace") annoyingly returns nil instead of erroring,
		-- so we try it with capital first letter since all services have that
		local serviceName = splitPathNames[1]:gsub("^%l", string.upper)
		-- assert it exists just in case there's something else that causes
		-- GetService to return nil instead of erroring
		return assert(game:GetService(serviceName))
	end)
	if success then
		table.remove(splitPathNames, 1)
		return service, splitPathNames
	end

	error(`'{splitPathNames[1]}' is not a valid service name`)
end

local function getInstance<T>(instance: Instance, ...: string): T
	for _, childName in ipairs({ ... }) do
		local child = instance:FindFirstChild(childName)
		assert(child, string.format("%s is not a child of %s", childName, instance:GetFullName()))
		instance = child
	end

	-- We want this function to be callable with generic types
	return (instance :: any) :: T
end

local function Tog(pathString: string, propertyName: string, value: any, valueType: string)
	local fullPath = stringPath:split(".")
	local parentInstance, remainingPath = getParentInstanceFromPath(fullPath)
	local instance = getInstance(parentInstance, table.unpack(remainingPath))
	
	if valueType == "Bool" then
		if value == "true" then
			value = true
		elseif value == "false" then
			value = false
		else
			Menu.ReturnCode("A7")
			-- Idk what this is supposed to do but if you want to stop executing code here, uncomment the next line
			-- return
		end
	end

	instance[propertyName] = value
end
1 Like