Hey everyone, so I made a script today that is supposed to show an image with a fade in and out on a button click. It doesn’t work for some reason and idk why, I would really appreciate your help!
local GUI = script.Parent.Parent
local Image = game.StarterGui.UpdateGUI.PathChosen
script.Parent.MouseButton1Click:Connect(function()
if GUI.Toggle.Value == false then
GUI.Toggle.Value = true
for i = 1,100 do
Image.ImageTransparency -= 0.01
wait(0.01)
end
elseif
GUI.Toggle.Value == true then
GUI.Toggle.Value = false
for i = 1,100 do
Image.ImageTransparency += 0.01
wait(0.01)
end
end
end)
What’s not working? Are you getting errors? Is it not turning transparent? or is it, but it’s not going at the right speed?
I’d suggest throw a few print commands in your click connect to see where the problem begins, once you dont see a print command come up in console then you’ll have an idea where to start diagnosing
if think it’s because you forgot to define the player in the script but I am not 100% sure. most MouseButton1Click functions that are used in UI define the player kinda like this: local player = game.Players.LocalPlayer
or in your case:
local player = game.Players.LocalPlayer
local GUI = script.Parent.Parent
local Image = game.StarterGui.UpdateGUI.PathChosen
script.Parent.MouseButton1Click:Connect(function()
if GUI.Toggle.Value == false then
GUI.Toggle.Value = true
for i = 1,100 do
Image.ImageTransparency -= 0.01
wait(0.01)
end
else
GUI.Toggle.Value == true then
GUI.Toggle.Value = false
for i = 1,100 do
Image.ImageTransparency += 0.01
wait(0.01)
end
end
local GUI = script.Parent.Parent
local plr = game.Players.LocalPlayer
local Image = plr.PlayerGui.UpdateGUI.PathChosen
script.Parent.MouseButton1Click:Connect(function()
if GUI.Toggle.Value == false then
GUI.Toggle.Value = true
for i = 1,100 do
Image.ImageTransparency -= 0.01
wait(0.01)
end
else
GUI.Toggle.Value == true then
GUI.Toggle.Value = false
for i = 1,100 do
Image.ImageTransparency += 0.01
wait(0.01)
end
end
end)
Transaprency I guess
“Hey everyone, so I made a script today that is supposed to show an image with a fade in and out on a button click. It doesn’t work for some reason and idk why, I would really appreciate your help!”
local GUI = script.Parent.Parent
local plr = game.Players.LocalPlayer
local Image = plr.PlayerGui.UpdateGUI.PathChosen
script.Parent.MouseButton1Click:Connect(function()
if GUI.Toggle.Value == false then
GUI.Toggle.Value = true
for i = 1,100 do
Image.ImageTransparency -= 0.01
wait(0.01)
end
else
GUI.Toggle.Value == true
GUI.Toggle.Value = false
for i = 1,100 do
Image.ImageTransparency += 0.01
wait(0.01)
end
end
end)