Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make cutaway walls like the game "The Sims"?

Asked by 7 years ago
Edited 7 years ago

Is there any code that could hide the walls in the first floor and the walls in second floor?. I try to find it in the wiki but it only hides in first floor, please help me solve this. ( here's the code that I found in wiki.)

local roomTransparency = 1

local player = game.Players.LocalPlayer
local currentRoom = nil

local function setLocalTransparency(object, transparency)
    if object:IsA('BasePart') then
        object.LocalTransparencyModifier = transparency
    end
    for _, child in ipairs(object:GetChildren()) do
        setLocalTransparency(child, transparency)
    end
end

local function setRoomTransparency(room, transparency)
    local hide = room:FindFirstChild("Hide")
    if hide then
        setLocalTransparency(hide, transparency)
    end
end

local function resetCurrentRoom()
    if currentRoom then
        setRoomTransparency(currentRoom, 0)
        currentRoom = nil
    end
end

while wait() do
    if player.Character then
        local torso = player.Character:WaitForChild('Torso')
        local ray = Ray.new(torso.Position, Vector3.new(0, -10, 0))

        local ignoreList = {}
        for _, child in pairs(game.Workspace:GetChildren()) do
            if child.Name ~= "LevelGeometry" then
                table.insert(ignoreList, child)
            end
        end

        local part = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)
        if part and part.Name == "Floor" then
            if part.Parent ~= currentRoom then
                resetCurrentRoom()
                currentRoom = part.Parent
                setRoomTransparency(currentRoom, roomTransparency)
            end
        else
            resetCurrentRoom()
        end
    end
end

Any help or comments would be appreciated.

Answer this question