What I am trying to recreate is the journal from Phasmophobia on steam, basically, you have 8 evidence, and when you get one, some of the names that aren't possible gets set to 0.8 transparency, eventually with 3 evidence it will tell you the exact type, however since I am new to scripting, I have a few issues. The main one being that when you remove an evidence, some of the types gets overwritten and the journal ends up telling you the wrong thing, as you can see in the link below. The second issue is that the script is written in the worst way possible and I need help with optimisation.
https://streamable.com/10w97q (vid depicting how the journal is supposed to work)
And heres the line of code that is used for every single evidence
script.Parent.CONCLUSION.EMF.MouseButton1Click:Connect(function() if script.Parent.CONCLUSION.EMF.ImageTransparency == 0 then script.Parent.CONCLUSION.EMF.ImageTransparency = 1 local all_evidence = script.Parent.CONCLUSION:GetChildren() for _i,v in pairs(all_evidence) do if v.ClassName == "Frame" then local evidence = v:FindFirstChild("EMF") if not evidence then v.NAME.TextTransparency = 0 end end end elseif script.Parent.CONCLUSION.EMF.ImageTransparency == 1 then script.Parent.CONCLUSION.EMF.ImageTransparency = 0 local all_evidence = script.Parent.CONCLUSION:GetChildren() for _i,v in pairs(all_evidence) do if v.ClassName == "Frame" then local evidence = v:FindFirstChild("EMF") if not evidence then v.NAME.TextTransparency = 0.8 end end end end end)
This line of code is copy and pasted for all 8 evidence, and that is the issue, but I do not know how to write it in any other way...
Thanks to everyone that helps in advance.