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 = true
else
if EMUOn == true then
EMUOn = false
end
end
end)
script.Parent.MMU.MouseButton1Click:Connect(function()
print("click")
if MMUOn == false then
MMUOn = true
else
if MMUOn == true then
MMUOn = false
end
end
end)
if MMUOn == false then
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
end
end
end
MMUOn = true
else
if MMUOn == true then
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 = false
end
end
if EMUOn == false then
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
end
end
end
EMUOn = true
else
if EMUOn == true then
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 = false
end
end
This entire part of the code should only run once
Is the script being cloned/are there multiple?
Is there more to the script like a loop surrounding the whole thing?
Have you tried putting print statements inside the if EMUOn / MMUOn statements to see if theyre the things running over and over again causing the problem?
It seems very weird that something that runs once would infinitely loop over and over again, given the information Im given
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 = true
else
if EMUOn == true then
EMUOn = false
end
end
end)
script.Parent.MMU.MouseButton1Click:Connect(function()
print("click")
if MMUOn == false then
MMUOn = true
else
if MMUOn == true then
MMUOn = false
end
end
end)
if MMUOn == false then
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
end
end
end
MMUOn = true
else
if MMUOn == true then
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 = false
end
end
if EMUOn == false then
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
end
end
end
EMUOn = true
else
if EMUOn == true then
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 = false
end
end
That is the entirety of the script, I’m presuming it’s something to do with the for loop and that it’s looping the transparency of the objects over and over again.
The if statements and for in pairs loops at the very bottom of your script is not connected to any events and also isn’t within a function is that intentional. @TrojanHorseAttack
I was going to recommend you disable the local script before parenting back into the player**.
But I’m not sure that would change anything.
Since local scripts only work within decedents of a player.
I will test to see if it needing to be disabled could be the problem brb.