- What do you want to achieve?
- What is the issue?
- What solutions have you tried so far?
May I just say ur code is really messy. The best way to do this would just to put all the parts in a model and then loop through them all. Would make the code more neat.
Also why do you have the “;” at the end of each of the property changes. In lula you don’t need the “;” at the end.
Yea some languages require you to use semi colons but Lua is not one of them.
Can you show me your workspace (how the different screen things are organised) Ignore this
Ok here I made some simple code which should work:
local PreScreen2 = game.Workspace.PreScreen2
local PreScreen = game.Workspace.PreScreen
local button = script.Parent
button.MouseButton1Click:Connect(function()
for i, v in pairs(PreScreen:GetChildren()) do
if v:IsA("BasePart") then
v.Transparency = 0
v.CanCollide = true
end
end
for i, v in pairs(PreScreen2:GetChildren()) do
if v:IsA("BasePart") then
v.Transparency = 0
v.CanCollide = true
end
end
end)
Please note that it seems like your doing this code inside of a local script which would mean that the screens will only show for the admin who clicked the button! If you want everyone to do this you would need to use a remote event to do this code in the server side!
You really should not be doing things related to UI in side of a server script (e.g MouseButton1Click).
Great to hear it worked! If you use remote events just ensure you protect your server (e.g checking the user who the event comes from is an admin)
If your not use how to protect your server here is a tutorial I made: