Tweening Transparency on a touch

It seems to not be rendering the player being inside the building

Here is a photo of the model if you’d like it:

1 Like

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:

1 Like

add a debounce to it, for the detection part

basically make it CanCollide to true and CanTouch to false, then once that debounce is over put them in their original values

1 Like

I do not have much experience with debounce. Do you mind adding that to the script for me?

1 Like

Debounce is basically like a wait, like a timer. Reading this could help you

1 Like

So how and where do I input this debounce code?

It’s because the tween takes too long and debounce won’t fix it unless you make the door collidable till tween finishes.

Think of it as a bunch of cockroaches swarming your house. You kill one, more came.

1 Like

put it in the touching line

if touching == false and debounce == false then
  debounce = true
  touching = true
  TweenOut:Play()
  wait(1)
  debounce = false
else
  debounce = true
  touching = false
  TweenIn:Play()
  wait(1)
  debounce = false
end

something like this

You need to set debounce to false at the end and to true at the start

You could make teleporters, one outside, one inside with a debounce in them. Debounce works like this:

local debounce = false
--Function
if not debounce then
debounce = true
task.wait(time_here)
debounce = false
end

that was a mistake on my end, i just realized after i posted it

Also I made a comment too if you didn’t see lol.
Also does the build mode fire once you touch the door or something?

I will try my best to be very descriptive,

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.

I dont think a telaporter would work

1 Like

A teleporter would work as long as the zombies have a humanoid, which I’m sure they do.
Just detect humanoid, if found, teleport inside.

1 Like

Also go into StarterPlayer and find something called “DevCameraOcclusionMode”
Try changing it to “Invisicam” and test it.

Sorry, made a typo. Fixed now*

Invisicam does what you want to.

1 Like

So I’m a bit confused. I have 3 codes:

Mine:

local roof = script.Parent.Roof

Info = TweenInfo.new(1)
local TweenIn = game:GetService("TweenService"):Create(roof,Info,{Transparency=0})
local TweenOut = game:GetService("TweenService"):Create(roof,Info,{Transparency=1})
local detection1 = script.Parent.Touch1
local detection2 = script.Parent.Touch2

local touching = false

detection1.Touched:Connect(function()
	detection1.CanTouch = false
	if touching == false then
		touching = true
		TweenOut:Play()
	else
		touching = false
		TweenIn:Play()
	end
	wait(1)
	detection1.CanTouch = true
end)

detection2.Touched:Connect(function()
	detection1.CanTouch = false
	if touching == false then
		touching = true
		TweenOut:Play()
	else
		touching = false
		TweenIn:Play()
	end
	wait(1)
	detection1.CanTouch = true
end)```

And add this:

local debounce = false
–Function
if not debounce then
debounce = true
task.wait(time_here)
debounce = false
end

How do I combine the two?

It isn’t a code.
Scroll down in Explorer and find StarterPlayer.
Click StarterPlayer and in Properties, find the “DevCameraOcclusionMode”
Switch it to “invisicam”.

Should work.

What does this do?

My game has not changed

If I remember correctly, if there is a roof above you, the roof will become translucent.

It’s basically what you need.