How to Change Part Transparency locally on Part Touch

  1. What do you want to achieve?*
    Change Part Transparency locally when player touches a part

  2. What is the issue?
    Can’t get it to work.

  3. What solutions have you tried so far?
    tried putting scripts in a part, in StarterPlayer Scripts, StarterCharacter Scripts, tried a normal script and local script

Here’s my code
– lobby

local LobbyWalls1 = game.Workspace.LevelWalls.LobbyWallFrontTop
local LobbyWalls2 = game.Workspace.LevelWalls.LobbyWall

– level 1

local lvl1walls1 = game.Workspace.LevelWalls.Wall1Front
local lvl1walls2 = game.Workspace.LevelWalls.Wall1Back
local lvl1walls3 = game.Workspace.LevelWalls.Wall1Left
local lvl1walls4 = game.Workspace.LevelWalls.Wall1Right
local lvl1walls5 = game.Workspace.LevelWalls.Wall1Up

– level 2

local lvl2walls1 = game.Workspace.LevelWalls.Wall2Front
local lvl2walls2 = game.Workspace.LevelWalls.Wal12Back
local lvl2walls3 = game.Workspace.LevelWalls.Wall2Left
local lvl2walls4 = game.Workspace.LevelWalls.Wall2Right
local lvl2walls5 = game.Workspace.LevelWalls.Wall2Top

–level 3

local lvl3walls1 = game.Workspace.LevelWalls.Wall3Front
local lvl3walls2 = game.Workspace.LevelWalls.Wall3Back
local lvl3walls3 = game.Workspace.LevelWalls.Wall3Left
local lvl3walls4 = game.Workspace.LevelWalls.Wall3Right
local lvl3walls5 = game.Workspace.LevelWalls.Wall3Top

–level 4

local lvl4walls1 = game.Workspace.LevelWalls.Wall4Front
local lvl4walls2 = game.Workspace.LevelWalls.Wall4Back
local lvl4walls3 = game.Workspace.LevelWalls.Wall4Left
local lvl4walls4 = game.Workspace.LevelWalls.Wall4Right
local lvl4walls5 = game.Workspace.LevelWalls.Wall4Top

–level 5

local lvl5walls1 = game.Workspace.LevelWalls.Wall5Front
local lvl5walls2 = game.Workspace.LevelWalls.Wall5Back
local lvl5walls3 = game.Workspace.LevelWalls.Wall5Left
local lvl5walls4 = game.Workspace.LevelWalls.Wall5Right
local lvl5walls5 = game.Workspace.LevelWalls.Wall5Top

–level 6

local lvl6walls1 = game.Workspace.LevelWalls.Wall6Front
local lvl6walls2 = game.Workspace.LevelWalls.Wall6Back
local lvl6walls3 = game.Workspace.LevelWalls.Wall6Left
local lvl6walls4 = game.Workspace.LevelWalls.Wall6Right
local lvl6walls5 = game.Workspace.LevelWalls.Wall6Top

–level 7

local lvl7walls1 = game.Workspace.LevelWalls.Wall7Front
local lvl7walls2 = game.Workspace.LevelWalls.Wall7Back
local lvl7walls3 = game.Workspace.LevelWalls.Wall7Left
local lvl7walls4 = game.Workspace.LevelWalls.Wall7Right
local lvl7walls5 = game.Workspace.LevelWalls.Wall7Top

–level 8

local lvl8walls1 = game.Workspace.LevelWalls.Wall8Front
local lvl8walls2 = game.Workspace.LevelWalls.Wall8Back
local lvl8walls3 = game.Workspace.LevelWalls.Wall8Left
local lvl8walls4 = game.Workspace.LevelWalls.Wall8Right
local lvl8walls5 = game.Workspace.LevelWalls.Wall8Top

–level 9

local lvl9walls1 = game.Workspace.LevelWalls.Wall9Front
local lvl9walls2 = game.Workspace.LevelWalls.Wall9Back
local lvl9walls3 = game.Workspace.LevelWalls.Wall9Left
local lvl9walls4 = game.Workspace.LevelWalls.Wall9Right
local lvl9walls5 = game.Workspace.LevelWalls.Wall9Top

–level 10

local lvl10walls1 = game.Workspace.LevelWalls.Wall10Front
local lvl10walls2 = game.Workspace.LevelWalls.Wall10Front2
local lvl10walls3 = game.Workspace.LevelWalls.Wall10Back
local lvl10walls4 = game.Workspace.LevelWalls.Wall10Back2
local lvl10walls5 = game.Workspace.LevelWalls.Wall10Left
local lvl10walls6 = game.Workspace.LevelWalls.Wall10Left2
local lvl10walls7 = game.Workspace.LevelWalls.Wall10Right
local lvl10walls8 = game.Workspace.LevelWalls.Wall10Right2
local lvl10walls9 = game.Workspace.LevelWalls.Wall10Top

–level 11

local lvl11walls1 = game.Workspace.LevelWalls.Wall11Front
local lvl11walls2 = game.Workspace.LevelWalls.Wall11Back
local lvl11walls3 = game.Workspace.LevelWalls.Wall11Left
local lvl11walls4 = game.Workspace.LevelWalls.Wall11Right
local lvl11walls5 = game.Workspace.LevelWalls.Wall11Top

–level 12

local lvl12walls1 = game.Workspace.LevelWalls.Wall12Front

local lvl12walls2 = game.Workspace.LevelWalls.Wall12Back
local lvl12walls3 = game.Workspace.LevelWalls.Wall12Left
local lvl12walls4 = game.Workspace.LevelWalls.Wall12Right
local lvl12walls5 = game.Workspace.LevelWalls.Wall12Top

–level 13

–No Walls

local part = workspace:WaitForChild(“lvl13Activate”)

part.Touched:Connect(function(hit)

if (hit.Parent:FindFirstChildWhichIsA(“Humanoid”)) and (hit.Parent:FindFirstChild(“Humanoid”) == game.Players.LocalPlayer.Character:FindFirstChild(“Humanoid”)) then

–Lobby

LobbyWalls1.Transparency = 1
LobbyWalls2.Transparency = 1

–level 1

lvl1walls1.Transparency = 1
lvl1walls2.Transparency = 1
lvl1walls3.Transparency = 1
lvl1walls4.Transparency = 1
lvl1walls5.Transparency = 1

– level 2

lvl2walls1.Transparency = 1
lvl2walls2.Transparency = 1
lvl2walls3.Transparency = 1
lvl2walls4.Transparency = 1
lvl2walls5.Transparency = 1

–level 3

lvl3walls1.Transparency = 1
lvl3walls2.Transparency = 1
lvl3walls3.Transparency = 1
lvl3walls4.Transparency = 1
lvl3walls5.Transparency = 1

–level 4

lvl4walls1.Transparency = 1
lvl4walls2.Transparency = 1
lvl4walls3.Transparency = 1
lvl4walls4.Transparency = 1
lvl4walls5.Transparency = 1

–level 5

lvl5walls1.Transparency = 1
lvl5walls2.Transparency = 1
lvl5walls3.Transparency = 1
lvl5walls4.Transparency = 1
lvl5walls5.Transparency = 1

–level 6

lvl6walls1.Transparency = 1
lvl6walls2.Transparency = 1
lvl6walls3.Transparency = 1
lvl6walls4.Transparency = 1
lvl6walls5.Transparency = 1

–level 7

lvl7walls1.Transparency = 1
lvl7walls2.Transparency = 1
lvl7walls3.Transparency = 1
lvl7walls4.Transparency = 1
lvl7walls5.Transparency = 1

–level 8

lvl8walls1.Transparency = 1
lvl8walls2.Transparency = 1
lvl8walls3.Transparency = 1
lvl8walls4.Transparency = 1
lvl8walls5.Transparency = 1

–level 9

lvl9walls1.Transparency = 1
lvl9walls2.Transparency = 1
lvl9walls3.Transparency = 1
lvl9walls4.Transparency = 1
lvl9walls5.Transparency = 1

–level 10

lvl10walls1.Transparency = 1
lvl10walls2.Transparency = 1
lvl10walls3.Transparency = 1
lvl10walls4.Transparency = 1
lvl10walls5.Transparency = 1
lvl10walls6.Transparency = 1
lvl10walls7.Transparency = 1
lvl10walls8.Transparency = 1
lvl10walls9.Transparency = 1

–level 11

lvl11walls1.Transparency = 1
lvl11walls2.Transparency = 1
lvl11walls3.Transparency = 1
lvl11walls4.Transparency = 1
lvl11walls5.Transparency = 1

–level 12

lvl12walls1.Transparency = 1
lvl12walls2.Transparency = 1
lvl12walls3.Transparency = 1
lvl12walls4.Transparency = 1
lvl12walls5.Transparency = 1

–level 13

end

end)

Okay, if you want a part to change its transparency locally you’d need to use a LocalScript. Putting it in workspace won’t work, so we can set it in StarterGui, or StarterCharacterScripts.

Using this code we can change a part’s transparency to a specific number:

local partToSet = -- Location of the part!
partToSet.Transparency = 1 -- Set it invisible!

This should work and function properly, for more info, feel free to look at this link about LocalScripts!
Peace, and good luck with your project!

I do have the Local script in StarterCharacterScripts but it does not work, im just not sure whats wrong. i have the same script format on my other local scripts using a part to change other things, but i cant get this one in particular to work.

Your code is too long for no real reason you could use a function or a module to make this easier, shorter, and better to understand
Or probably make it neater and more accessible by using folders

Alright, so if you want it as for it to be invisible when touched, here’s this:

local TriggerPart = -- Part to touch.
local InvisiblePart = -- Part to make invisible!
TriggerPart.Touched:Connect(function(part)
    if part and part.Parent:FindFirstChildOfClass("Humanoid") then
        InvisiblePart.Transparency = 1
    end
end)

This should work! : D

1 Like

I think i figured out the problem… when i get rid of the Comment lines its works. Strange. Bug?

I don’t know lol. Probably a bug. You can always report them here on the DevForm! I’m glad you figured it out!

1 Like

I know a code for invisible on part, it’s

script.parent.touched:Connect(function()
script.parent.transparency = 1