I am trying to make it so when the player is not inside a building, the interior of the building is not visible
But when the player IS Inside the building, the inside of the building is!
Here is my tween code for transparency:
local Info = TweenInfo.new(1)
local TweenIn = game:GetService("TweenService"):Create(script.Parent,Info,{Transparency=0})
local TweenOut = game:GetService("TweenService"):Create(script.Parent,Info,{Transparency=1})
TweenOut:Play() -- Makes The Inside Of The Building Visible
TweenIn:Play() -- Makes The Inside Of The Building Not Visible
Store the stuff you want invisible in a separate folder.
Note, if you have models, check for models, then run another loop to make the stuff inside the model invisible too.
Also just edit the tween script in between it like:
local invis = game.Workspace.Path_Invisible_Folder
for i, v in pairs(invis:GetChildren()) do
if v:IsA(“BasePart”) then
local Info = TweenInfo.new(1)
local TweenIn = game:GetService("TweenService"):Create(v,Info,{Transparency=0})
local TweenOut = game:GetService("TweenService"):Create(v,Info,{Transparency=1})
TweenOut:Play()
--TweenIn:Play() for when you exit build mode.
end
end
Place this in like the script that enters you into build mode.
-- Local Script
local RunService = game:GetService('RunService')
local Plr = game:GetService('Players').LocalPlayer
local Building = -- Path to building
local Roof = Building.Roof
RunService.RenderStepped:Connect(function()
local isInside = false
for _, Touching in workspace:GetPartsInPart(Building.Inside) do
if Touching.Parent == Plr.Character then
isInside = true
break
end
end
if isInside then
Roof.Transparency = Roof.Transparency:Lerp(1,.2)
else
Roof.Transparency = Roof.Transparency:Lerp(0,.2)
end
end)
Try making a part that covers the whole building or just the door, and then detect when the player touches that part. When it does, tween the roof part. It may not be the best solution, but that’s all I can think of for now.
local Info = TweenInfo.new(1)
local TweenIn = game:GetService("TweenService"):Create(script.Parent,Info,{Transparency=0})
local TweenOut = game:GetService("TweenService"):Create(script.Parent,Info,{Transparency=1})
local detection = script.Parent.Parent.Detect --part in model/building
local touching = false
detection.Touched:Connect(function()
if touching == false then
touching = true
TweenOut:Play()
else
touching = false
TweenIn:Play()
end
end)
-- its just something i thought of, it might not even work lol
This was my original Idea but the problem is the player can glitch i by walking in and out real fast and then walking back in and it will appear like this:
This game is a zombie game, Zombies will chase you and you can loot houses to get upgrades BUT I don’t want players to be able to see whats inside the home until they enter.
Also, the doors do not close but only open so zombies can follow the player.