So ive been making this script that goes into a proximityprompt. It make the prompt work as a switch that makes certain things invisible and play certain audios. And i have this other local script that goes inside an imagelabel in startergui that resets the parts to be visible again. I made this script check to see when a certain part is visible or not it will do the respective action. But even with that check it always does whatever the next part of the toggle. I beent rying to fix this for liek 5 hours and rescripting but i have no idea why i cant make ti work
local proximityPrompt = script.Parent -- Assuming the proximity prompt is a direct child of the part
local part1 = proximityPrompt.Parent.Switch -- Replace 'Switch' with the name of your first part
local part2 = proximityPrompt.Parent.Switch2 -- Replace 'Switch2' with the name of your second part
local beam1 = game.Workspace.BasementRooms.Server_Room.Damonitros.PCSCREEN1.Beam
local beam2 = game.Workspace.BasementRooms.Server_Room.Damonitros.PCSCREEN2.Beam
local beam3 = game.Workspace.BasementRooms.Server_Room.Damonitros.PCSCREEN3.Beam
local beam4 = game.Workspace.BasementRooms.Server_Room.Damonitros.PCSCREEN4.Beam
local beam5 = game.Workspace.BasementRooms.Server_Room.Damonitros.PCSCREEN5.Beam
local beam6 = game.Workspace.BasementRooms.Server_Room.Damonitros.PCSCREEN6.Beam
local screen1 = game.Workspace.BasementRooms.Server_Room.Damonitros.Screen1
local screen2 = game.Workspace.BasementRooms.Server_Room.Damonitros.Screen2
local screen3 = game.Workspace.BasementRooms.Server_Room.Damonitros.Screen3
local screen4 = game.Workspace.BasementRooms.Server_Room.Damonitros.Screen4
local screen5 = game.Workspace.BasementRooms.Server_Room.Damonitros.Screen5
local screen6 = game.Workspace.BasementRooms.Server_Room.Damonitros.Screen6
local audio = game.Workspace.Audio.switch1
local audio2 = game.Workspace.Audio.switch12
local cooldown = 1
local canToggle = true
-- BoolValue to control the state
local isScriptEnabled = script:WaitForChild("IsEnabled", 2) or Instance.new("BoolValue")
isScriptEnabled.Name = "IsEnabled"
isScriptEnabled.Value = true
isScriptEnabled.Parent = script
-- Function to toggle transparency
local function toggleTransparency()
if canToggle then
canToggle = false
if part1.Transparency == 0 then
part1.Transparency = 1
part2.Transparency = 0
audio.Playing = true
screen1.Color = Color3.new(0.105882, 0.164706, 0.207843)
screen2.Color = Color3.new(0.105882, 0.164706, 0.207843)
screen3.Color = Color3.new(0.105882, 0.164706, 0.207843)
screen4.Color = Color3.new(0.105882, 0.164706, 0.207843)
screen5.Color = Color3.new(0.105882, 0.164706, 0.207843)
screen6.Color = Color3.new(0.105882, 0.164706, 0.207843)
beam1.Enabled = false
beam2.Enabled = false
beam3.Enabled = false
beam4.Enabled = false
beam5.Enabled = false
beam6.Enabled = false
elseif part1.Transparency == 1 then
part1.Transparency = 0
part2.Transparency = 1
audio2.Playing = true
screen1.Color = Color3.new(0.172549, 0.396078, 0.113725)
screen2.Color = Color3.new(0.172549, 0.396078, 0.113725)
screen3.Color = Color3.new(0.172549, 0.396078, 0.113725)
screen4.Color = Color3.new(0.172549, 0.396078, 0.113725)
screen5.Color = Color3.new(0.172549, 0.396078, 0.113725)
screen6.Color = Color3.new(0.172549, 0.396078, 0.113725)
beam1.Enabled = true
beam2.Enabled = true
beam3.Enabled = true
beam4.Enabled = true
beam5.Enabled = true
beam6.Enabled = true
end
wait(cooldown)
canToggle = true
end
end
proximityPrompt.Triggered:Connect(toggleTransparency)