[SOLVED] Can't Get Script Working

Hello. I have been trying to figure out how to fix this script for a while, and I can’t figure it out. I am new to scripting, so I’m sorry if the answer is extremely obvious. Here is the script.

Script

if game.Lighting[“Tropical Breeze”] == true then

game.Workspace.GoAway.Transparency = 1
game.Workspace.GoAway.GoAway2.Transparency = 1
game.Workspace.GoAway.Decal.Transparency = 1

or game.Lighting[“Bottomless Pit”] == true

game.Workspace.GoAway.Transparency = 1
game.Workspace.GoAway.GoAway2.Transparency = 1
game.Workspace.GoAway.Decal.Transparency = 1

else

game.Workspace.GoAway.Transparency = 0
game.Workspace.GoAway.GoAway2.Transparency = 0
game.Workspace.GoAway.Decal.Transparency = 0
end

The script is supposed to make some bricks go invisible when the map is chosen. I know this is for sure not an effective way to script something to do this, but it’s the best I can do. If you know a more effective method to do this, feel free to share it.

Thank you for reading, have a nice day!

3 Likes

What type of objects are [“Bottomless Pit”] and [“Tropical Breeze”]? You might need to add a .Value after that.

Hello. Those objects are models, they are the maps that are in the game.

A model will never equal true, as an instance and bool are not the same things. If you want to check for the existence of a model you would use if game.Lighting:FindFirstChild(“Tropical Breeze”) then

Also, when you write or game.Lighting[“Bottomless Pit”] == true, you need to use elseif instead of or, those two do very different things.

This should be a better-revised script for you.

if game.Lighting:FindFirstChild(“Tropical Breeze”) then
    game.Workspace.GoAway.Transparency = 1
    game.Workspace.GoAway.GoAway2.Transparency = 1
    game.Workspace.GoAway.Decal.Transparency = 1
elseif game.Lighting:FindFirstChild(“Bottomless Pit”)  then
    game.Workspace.GoAway.Transparency = 1
    game.Workspace.GoAway.GoAway2.Transparency = 1
    game.Workspace.GoAway.Decal.Transparency = 1
else
    game.Workspace.GoAway.Transparency = 0
    game.Workspace.GoAway.GoAway2.Transparency = 0
    game.Workspace.GoAway.Decal.Transparency = 0
end

Hope this helps please let me know if it worked.

Hello. Thank you for trying to help, but it didn’t work. I have no idea why. By the way, I want it to be invisible if either of them are in Workspace. Not sure if that would make a difference.

It would. This should work then:

if game.Workspace:FindFirstChild(“Tropical Breeze”) or game.Workspace:FindFirstChild(“Bottomless Pit”) then
    game.Workspace.GoAway.Transparency = 1
    game.Workspace.GoAway.GoAway2.Transparency = 1
    game.Workspace.GoAway.Decal.Transparency = 1
else
    game.Workspace.GoAway.Transparency = 0
    game.Workspace.GoAway.GoAway2.Transparency = 0
    game.Workspace.GoAway.Decal.Transparency = 0
end

If you want to see if they are in workspace, you need to make sure you are looking for them in workspace, not lighting. Also I moved the elseif line to the top and changed it to or so your code would be more compact.

Thanks, but for some reason it still isn’t working. Do you think it might not work in studio?

It should? Perhaps give me more information about what these things are in workspace and how they are getting there? Are there any errors? I simply just need more information to be able to further explain.

Okay. I have a script that brings these models (maps) from Lighting to Workspace. I have no problems with them getting there. That script is supposed to make it so the intermission screen goes invisible. I just thought that I could possibly make it a GUI instead of a giant brick with a decal. No idea if that would be better.

How about when the script moves the maps from lighting to workspace, that same script fires all clients with a remote event to disable the intermission gui. When the map goes away, that same script fires all clients to enable that gui.

1 Like

That’s a good idea, I will try it out. Thanks!

1 Like

I actually found out how to fix the script. I was wondering what happened, so I tried fixing it. This is what it looks like now.

while true do
    wait(0)
    if game.Workspace:FindFirstChild("Tropical Breeze") or game.Workspace:FindFirstChild("Bottomless Pit") then
	game.Workspace.GoAway.Transparency = 1
	game.Workspace.GoAway.GoAway2.Transparency = 1
	game.Workspace.GoAway.Decal.Transparency = 1
else
	game.Workspace.GoAway.Transparency = 0
	game.Workspace.GoAway.GoAway2.Transparency = 0
	game.Workspace.GoAway.Decal.Transparency = 0
    end
end

Thanks for the help!

1 Like