Need Help Making A Texture Appear when a button is clicked

Hey Developers!

So I am making a FNaF game, but my door script that is supposed to make the texture appear is not working

Here is the script:


if game.Workspace.LeftDoor.Closed.Value == false then

if game.Workspace.Power.Value <= 0 then return end

game.Workspace.LeftDoor.Sound:Play()

game.Workspace.LeftDoor.Transparency = 0

game.Workspace.LeftDoor.Decal.Transparency = 0

game.Workspace.LeftDoor.CanCollide = true

game.Workspace.LeftDoor.Closed.Value = true

game.Workspace.Usage.Value = game.Workspace.Usage.Value + 2

game.Workspace.LeftDoor.Texture.Transparency = 1

else

game.Workspace.LeftDoor.Sound:Play()

game.Workspace.LeftDoor.Transparency = 1

game.Workspace.LeftDoor.Decal.Transparency = 1

game.Workspace.LeftDoor.CanCollide = false

game.Workspace.LeftDoor.Closed.Value = false

game.Workspace.Usage.Value = game.Workspace.Usage.Value - 2

game.Workspace.LeftDoor.Texture.Transparency = 0

end

end

script.Parent.ClickDetector.MouseClick:connect(click)```


--If I didn't explain clearly you can ask me anything
2 Likes

Hi. Can you please put your code in between grave marks (```) so it is formatted like code and make the indentations right pls?

It would look like this

function click()
  if game.Workspace.LeftDoor.Closed.Value == false then
     if game.Workspace.Power.Value <= 0 then return end
     game.Workspace.LeftDoor.Sound:Play()
     game.Workspace.LeftDoor.Transparency = 0
     game.Workspace.LeftDoor.Decal.Transparency = 0
     game.Workspace.LeftDoor.CanCollide = true
     game.Workspace.LeftDoor.Closed.Value = true
     game.Workspace.Usage.Value = game.Workspace.Usage.Value + 2
     game.Workspace.LeftDoor.Texture.Transparency = 1
  else
     game.Workspace.LeftDoor.Sound:Play()
     game.Workspace.LeftDoor.Transparency = 1
     game.Workspace.LeftDoor.Decal.Transparency = 1
     game.Workspace.LeftDoor.CanCollide = false
     game.Workspace.LeftDoor.Closed.Value = false
     game.Workspace.Usage.Value = game.Workspace.Usage.Value - 2
     game.Workspace.LeftDoor.Texture.Transparency = 0
  end
end

script.Parent.ClickDetector.MouseClick:connect(click)

Also, are you getting any errors in the console?

Done, thank you, I didn’t know about that
And nope, everything good

The Texture property of a Decal does not have a Transparency. My guess is that it errors at line 10, and doesn’t continue with the script.

You can either make the Decal’s transparency 0 (which you’re already doing) or set the Texture ID to 0, which will remove it both ways.

I hope this helped.