So in my main menu, I have a splash button that when clicked on, takes you to my YouTube page. I also tried to code in that there’s a 1 in 5 chance it sends you to a rickroll.
The code i used for it is as following(I only included the part thats not working how I intend)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MainMenu : MonoBehaviour
{
public void SplashButton()
{
float FunValue = Random.Range(1f, 5f);
if (FunValue == 5f)
{
Application.OpenURL("https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley");
Debug.Log("Get rickrolled lol");
}
if (FunValue < 5f)
{
Application.OpenURL("My YouTube page.[yeah i know, i dont really want to share a link here]");
Debug.Log("Ma YT page!!1");
}
Debug.Log("SplashButton was clicked.");
}
}
When clicked on the button that runs SplashButton() , it does take you to my youtube page. But when I tried it out, the rickroll thing never comes. I have tried it at least 20 times, it doesn’t work.
I do think it has to do with the fact I messed up Random. I don’t get compiler errors, but like I said, the rickroll is not coming. What’s going on here?