Change part transparency through raycast

So, after looking through your other posts on the DevForum, I think that you may want to look into ZonePlus. With it, you will be able to detect when a player enters and leaves your building, and change the transparency of the corresponding roof. It will look something like this:

local player = game.Players.LocalPlayer
local Zone = require(Path.To.Zone)
local container = Container -- this is going to be a part that covers the entire building
local zone = Zone.new(container)

zone.localPlayerEntered:Connect(function()
    -- the player has entered the building, change the roof transparency
    correspondingRoof.Transparency = 0.8
end)

zone.localPlayerExited:Connect(function()
    -- the player left the building, change the transparency
    correspondingRoof.Transparency = 0
end)
1 Like