Hiding Textures

How do I make it so textures are hidden unless the player can physically see it?
To reduce lag, and to stop blocks from having weird black lines.

Wdym? Can you show a picture?

Also, maybe you could use dot product to see if it is on the player’s view, and if it isn’t, just set the transparency to 0 or make a table and blah blah? Though I don’t see how deleting/hiding textures would benefit much lag at all, easiest thing to do is to make a config where you make a table, get all textures parents and shove it into the table before moving them to like ReplicatedStorage or nil or smth so they aren’t rendered

Screen Shot 2024-09-16 at 7.28.21 PM
Here’s an image.

That’s really weird, to say the least. Is the image on the texture completely filled? Also, maybe try decals instead?

That unfortunately didn’t work. And I’m not actually sure how to do that Dot Product thingy, could you help with that if you don’t mind?

Sure… but why there are textures on the blocks? Is it because they are like grass or smth? But I could help with Dot Product. Here’s an example code (If you want more explanation, just ask :slight_smile:)

local Children = [BlockFolderHere]:GetChildren

for i,block in pairs(Children) do
	local Camera = workspace.Camera
	local dist = (block.Position-Camera.CFrame.Position).Unit --Normalised or else the dot product would be over 1, which we don't want

	local DotProduct = Camera.CFrame.LookVector:DotProduct(dist)
	
	if DotProduct >= 0 then --1 means its directly in front of the player, -1 means its behind, and 0 would be equal to 180 degrees or 90 i dunno
		print("In view") --Example
	end
end

I didn’t tested it in studio tho cuz my laptop is a Nokia Knockoff (It would take a while to open studio) but it should work

This sort of works, but there’s a bit of a delay unfortunately :frowning:
They have no texture until ~1 second of me looking at them

The code doesn’t use any while dos, could you share the code you did with my example? (Now I gtg since its night on where I am)

Screen Shot 2024-09-16 at 8.34.49 PM
so should i remove the while do?

Honestly, I don’t know why this is happening. My best bet is lag… and thinking now, I don’t think using that solution is a good idea, instead you probably want to make a option (Like in a configuration) that put all textures parents to nil if enabled, and if disabled put all of the textures back to their parent… Atleast I guess you learned a thing or two, I guess