Issues with part not becoming transparent


Hi! So, I wrote a script that when it’s clicked, the parent will have its transparency set to 1. AT the same time, another cube will have its transparency set to 0, so the player can see it. This is done in a Server-sided script.

  1. What is the issue?
    None of the cubes will appear/disappear upon being clicked but, the function doesn’t fire.

  2. What solutions have you tried so far?
    Added a print statement to see if it fired, it doesn’t. Tried changing the transparency values of the objects in the script. That didn’t work either.

 script.Parent.ClickDetector.MouseClick:Connect(function(PlayerWhoClicked) 
		
	if 	 script.Parent.Transparency == 0.9 then
		script.Parent.ParticleEmitter.Enabled = true
		wait(1)
		script.Parent.ParticleEmitter.Enabled = false
		script.Parent.Transparency = 1
		print("this print fired")
			script.Parent.Terrian2.Transparency = 0
	else
		script.Parent.ParticleEmitter.Enabled = true
		wait(1)
		script.Parent.ParticleEmitter.Enabled = false

			script.Parent.Transparency = 0.9
			script.Parent.Terrian2.Transparency = 1
		end
end)

-ps, I’m really not that good with scripting

If it’s a LocalScript, change it to Script.

1 Like

image
It’s already a script.

Is there a ClickDetector in the Part the script is in?

1 Like

Yes.
image

Use this and see if A or B prints:

local part = script.Parent
local emitter = part.ParticleEmitter

part.ClickDetector.MouseClick:Connect(function()
	if part.Transparency < 1 then
		print("A")
		emitter.Enabled = true
		task.wait(1)
		emitter.Enabled = false
		part.Transparency = 1
		part.Terrian2.Transparency = 0
	else
		print("B")
		emitter.Enabled  true
		task.wait(1)
		emitter.Enabled = false
		part.Transparency = 0.9
		part.Terrian2.Transparency = 1
	end
end)

its an optimized version :slight_smile:

2 Likes

You should probably learn how to spell Terrain as well, Terrian2 misspelled.
Do you get any errors in the Output window?

Edit, you also seem to be switching between Transparency 0, 0.9, and 1. You may want to see if you have an error with the script reading a Part that is Transparency 1 when it checks for 0.9.
@Dev_Ryan seems to have this worked out in their script.

Great! This script works! Thank you so much for helping.

1 Like

Instead of “You should probably learn how to spell Terrain as well”
you should say “By the way you misspelled Terrain”, it sounds less rude that way.

2 Likes