So I'm trying to make a gui button make the other buttons fade away when pressed. But for some reason, the MouseButton1Click won't work. Here's the code:
script.Parent.MouseButton1Click(function() local sound = Instance.new("Sound") sound.SoundId = "rbxasset://sounds//clickfast.wav" sound.Parent = script.Parent.Parent sound:play() wait(.25) for i = 0, 1, 0.01 do script.Parent.Parent.SpawnButton.BackgroundTransparency = i script.Parent.Parent.SpawnButton.TextTransparency = i script.Parent.Parent.ShopButton.BackgroundTransparency = i script.Parent.Parent.ShopButton.TextTransparency = i wait(0.01) end end)
Basically all that's keeping it from running is the MouseButton1Click event. This is what pops up in the output:
17:10:06.905 - Players.Player.PlayerGui.ScreenGui.StartScreen.ShopButton.L:2: attempt to call field 'MouseButton1Click' (a userdata value)
Help on what's happening, and why it confuses it for userdata value instead of a function would be appreciated!
The only thing that is wrong with the script is that you're connection line isn't complete.
script.Parent.MouseButton1Click:connect(function()---- i added :connect to the script local sound = Instance.new("Sound") sound.SoundId = "rbxasset://sounds//clickfast.wav" sound.Parent = script.Parent.Parent sound:play() wait(.25) for i = 0, 1, 0.01 do script.Parent.Parent.SpawnButton.BackgroundTransparency = i script.Parent.Parent.SpawnButton.TextTransparency = i script.Parent.Parent.ShopButton.BackgroundTransparency = i script.Parent.Parent.ShopButton.TextTransparency = i wait(0.01) end end)