This could be done even easier,
EMUOn = not EMUOn
This could be done even easier,
EMUOn = not EMUOn
That was said already, no offense
Okay so this is the updated code:
local MMUOn = true
local EMUOn = true
local player = game.Players.LocalPlayer
local character = player.Character
script.Parent.EMU.MouseButton1Click:Connect(function()
print("click")
if EMUOn == false then
EMUOn = not EMUOn
else
if EMUOn == true then
EMUOn = not EMUOn
end
end
end)
script.Parent.MMU.MouseButton1Click:Connect(function()
print("click")
if MMUOn == false then
MMUOn = not MMUOn
else
if MMUOn == true then
MMUOn = not MMUOn
end
end
end)
if MMUOn == false then
print("MMUOn false")
for i, v in pairs(character.MMUGroup:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Transparency = 0
else
if v:IsA("Decal") then
v.Transparency = 0.85
else
if v.Material == Enum.Material.Glass then
v.Transparency = 0.6
end
end
end
end
MMUOn = not MMUOn
else
if MMUOn == true then
print("MMUOn true")
for i, v in pairs(character.MMUGroup:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = true
v.Transparency = 1
else
if v:IsA("Decal") then
v.Transparency = 1
end
end
end
MMUOn = not MMUOn
end
end
if EMUOn == false then
print("EMUOn false")
for i, v in pairs(character.EMUGroup:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Transparency = 0
else
if v:IsA("Decal") then
v.Transparency = 0.85
else
if v.Material == Enum.Material.Glass then
v.Transparency = 0.6
end
end
end
end
EMUOn = not EMUOn
else
if EMUOn == true then
print("EMUOn true")
for i, v in pairs(character.EMUGroup:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = true
v.Transparency = 1
else
if v:IsA("Decal") then
v.Transparency = 1
end
end
end
EMUOn = not EMUOn
end
end
I’m receiving the print statements, but nothing seems to happen:
https://i.gyazo.com/8b98c3a64b7e44919b07079cf71fdcc6.mp4
local MMUOn = true
local EMUOn = true
local player = game.Players.LocalPlayer
local character = player.Character
local function MMUOn()
print("MMU On!")
for i, v in pairs(character.MMUGroup:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Transparency = 0
if v.Material == Enum.Material.Glass then
v.Transparency = 0.6
end
elseif v:IsA("Decal") then
v.Transparency = 0.85
end
end
end)
local function MMUOff()
print("MMUOff!")
for i, v in pairs(character.MMUGroup:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Transparency = 1
elseif v:IsA("Decal") then
v.Transparency = 1
end
end
end)
local function EMUOn()
print("EMU On!")
for i, v in pairs(character.EMUGroup:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Transparency = 0
if v.Material == Enum.Material.Glass then
v.Transparency = 0.6
end
elseif v:IsA("Decal") then
v.Transparency = 0.85
end
end
end)
local function EMUOff()
print("EMU Off!")
for i, v in pairs(character.EMUGroup:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Transparency = 1
elseif v:IsA("Decal") then
v.Transparency = 1
end
end
end)
script.Parent.EMU.MouseButton1Click:Connect(function()
EMUOn = not EMUOn
print("Clicked!")
if EMUOn then EMUOn() else EMUOff() end
end)
script.Parent.MMU.MouseButton1Click:Connect(function()
MMUOn= not MMUOn
print("Clicked!")
if MMUOn then MMUOn() else MMUOn() end
end)
Try this out?
Instead, when the buttons are clicked it will fire the function.
Your current code only changes the visibilities once.
That works for the first click, but I then can’t toggle the gear again: 21:48:16.426 Players.RhysFaber.PlayerGui.ToggleGear.LocalScript:63: attempt to call a boolean value - Client - LocalScript:63
script.Parent.EMU.MouseButton1Click:Connect(function()
EMUOn = not EMUOn
if EMUOn then EMUOn() else EMUOff() end
end)
script.Parent.MMU.MouseButton1Click:Connect(function()
MMUOn= not MMUOn
if MMUOn then MMUOn() else MMUOn() end
end)
Try replacing it with this?
script.Parent.EMU.MouseButton1Click:Connect(function()
EMUOn = not EMUOn
print("Clicked!")
if EMUOn == true then EMUOn() else EMUOff() end
end)
script.Parent.MMU.MouseButton1Click:Connect(function()
MMUOn = not MMUOn
print("Clicked!")
if MMUOn == true then MMUOn() else MMUOff() end
end)
I’m not too sure why it’s not working, to be honest.
This could be the reason, but I’m not understanding why it’s showing up
https://i.gyazo.com/b94cb3045ddecef5cb05bf490c8f692c.mp4
I’m not gonna lie, I have no idea anymore.
Getting this error if it helps
My bad, that was pretty dumb on my behalf.
I think the reason it is erroring is because the function and variable had the same names.
local MMUOn = true
local EMUOn = true
local player = game.Players.LocalPlayer
local character = game.Workspace
local function _MMUOn()
print("MMU ON")
for i, v in pairs(character.MMUGroup:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Transparency = 0
if v.Material == Enum.Material.Glass then
v.Transparency = 0.6
end
elseif v:IsA("Decal") then
v.Transparency = 0.85
end
end
end
local function _MMUOff()
print("MMU OFF")
for i, v in pairs(character.MMUGroup:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Transparency = 1
elseif v:IsA("Decal") then
v.Transparency = 1
end
end
end
local function _EMUOn()
print("EMU ON")
for i, v in pairs(character.EMUGroup:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Transparency = 0
if v.Material == Enum.Material.Glass then
v.Transparency = 0.6
end
elseif v:IsA("Decal") then
v.Transparency = 0.85
end
end
end
local function _EMUOff()
print("EMU OFF")
for i, v in pairs(character.EMUGroup:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Transparency = 1
elseif v:IsA("Decal") then
v.Transparency = 1
end
end
end
Hope this works out for you, let me know what happens!
Replace it with this, forgot about that.
script.Parent.EMU.MouseButton1Click:Connect(function()
EMUOn = not EMUOn
if EMUOn then _EMUOn() else _EMUOff() end
end)
script.Parent.MMU.MouseButton1Click:Connect(function()
MMUOn = not MMUOn
if MMUOn then _MMUOn() else _MMUOff() end
end)
Works 100%, thank you so much for all your help!
Anytime! Glad it worked.
…