My transparency script doesn't work

Hi,
I just created this transparency toggle change script but in game doesn’t work or doesn’t change
the transparency of part I want.

2 Likes

What script you used (local script or just normal script) where you it put and is there any errors also you can shorten the script just to

local isTransparent = false
local part =  script.Parent   
script.Parent.ProximityPrompt.Triggered:Connect(function()
    if isTransparent == false then -- If it's not transparent
        isTransparent  = true
        part .transparency = 1 -- We set it to one instead of doing unnecessary calculation 
        part.CanCollide = false
    else -- If it's transparent 
         isTransparent  = false
        part .transparency = 0-- We set it to one instead of doing unnecessary calculation 
        part.CanCollide = true
    end  
end)

Also if you want to write script format like i did on top use ``` this symbol

It doesn’t work and no errors or warnings too I don’t understand. I used normal script and put in a part.

the script is inside of workspace?

Are you correctly referencing .Transparency?

Yes it’s in the workspace and in a model of car.

Can you show the car model like how it’s organized

You cannot change the Transparency of a Model.


It’s inside the hood part right ?

Yes and I can’t write 3 letters so I’m writing long

I went in studio and teseted the script and it works fine did it work the first time when you triggered the prompt ?

No it didn’t I can’t write 3 letters so I’m writing long

I can try using “ClickDetector”.

Try this script and tell me what it printed

local isTransparent = false
local part =  script.Parent   
script.Parent.ProximityPrompt.Triggered:Connect(function()
	print("Triggered")	
	if isTransparent == false then -- If it's not transparent
		isTransparent  = true
		part.Transparency = 1 -- We set it to one instead of doing unnecessary calculation 
		part.CanCollide = false
	else -- If it's transparent 
		isTransparent  = false
		part.Transparency = 0-- We set it to one instead of doing unnecessary calculation 
		part.CanCollide = true
	end  
end)

In the image it seems working fine

Yes but the part doesn’t changing transparency. I’m gonna write the all code.