Basically, I'm making a GUI with a button, when you click it, it checks if there is a RemoteEvent present, which if it does, it works, but the else statement doesn't seem to work.
script.Parent.MouseButton1Click:Connect(function() if game.ReplicatedStorage.gui_instance ~= nil then game.ReplicatedStorage.gui_instance:FireServer() script.Parent.Parent.Parent.Frame.Visible = true script.Parent.Parent.Parent.Frame1:Remove() game.StarterGui:SetCore("SendNotification",{Title="Success!"; Text="GUI Attached!"}) else game.StarterGui:SetCore("SendNotification",{Title="Error"; Text="RemoteEvent not found!"}) wait(10) script.Parent.Parent.Parent.Parent.ScreenGui:Remove() end end)
First of all, you should not be using :Remove, use :Destroy instead. Also, your script will error out and stop if it is nil, so you should be using :FindFirstChild. Console would have also helped in this case so be sure to have it open.
script.Parent.MouseButton1Click:Connect(function() if game.ReplicatedStorage:FindFirstChild("gui_instance") then game.ReplicatedStorage.gui_instance:FireServer() script.Parent.Parent.Parent.Frame.Visible = true script.Parent.Parent.Parent.Frame1:Destroy() game.StarterGui:SetCore("SendNotification",{Title="Success!"; Text="GUI Attached!"}) else game.StarterGui:SetCore("SendNotification",{Title="Error"; Text="RemoteEvent not found!"}) wait(10) script.Parent.Parent.Parent.Parent.ScreenGui:Destroy() end end)
The code above should work, if you have any issues let me know. :)