How to make a part visible when touched and when not touched turn it back to transparent?

Making a game from a birds eye view and I want to make a map with multiple stories, and the only way to pull this off is to make the top floor invisible when your not on it and when you are, make the top floor visible.

I have that part done but the problem is that I can’t quite figure out how to change the top floor back to transparent when its not being touched again. My other problem is that everyone else experiences these changes when another player gets on the top floor and I want to make the transparency changes only be visible to the player who triggered them.

I haven’t found any solutions that quite matches mine very well.

3 Likes

There is an event that’s called .TouchEnded, is this what you were looking for perhaps?

3 Likes

Yeah maybe, Ill try that event real quick.

2 Likes

touch events are often unreliable. if you are experiencing inconveniences with this method, you should probably try a different one such as raycasting

Alright, No idea what Raycasting is, but ill try

This is what I would do:

local Part = script.Parent 

local function Touched()
Part.Transparensy = 1 
end)

local function Untouched()
Part.Transparensy = 0 
end)

Part.Touched:Connect(Touched)
Part.TouchEnded:Connect(Untouched)
1 Like

You should add an if statement to check for a player though right?

2 Likes

Oh, yeah, right:

local Part = script.Parent 

Part.Touched:Connect(function(Hit)
if Hit.Parent then 
Part.Transparency = 0
end)

Part.TouchEnded:Connect(function(Hit)
if Hit.Parent then 
Part.Transparency = 1
end)

Im getting a Weird error when I close a function. heres a screenshot:

Whoops it’s missing 2 ends,

local Part = script.Parent 

Part.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild(“Humanoid”) then
Part.Transparency = 0
end
end)

Part.TouchEnded:Connect(function(Hit)
if Hit.Parent:FindFirstChild(“Humanoid”) then 
Part.Transparency = 1
end
end)
3 Likes