Okay I want to use a function to fire off this while loop
while true do stats.Score.Value = stats.Score.Value + 1 local str = stats.Score.Value local str1 = "Your income: " player.PlayerGui.ScreenGui.Frame.TextButton.Text = str1..str wait(1) end
I fixed the script and this works
function onClick() while true do game.Players.LocalPlayer.leaderstats.Score.Value = game.Players.LocalPlayer.leaderstats.Score.Value + 1 local str = game.Players.LocalPlayer.leaderstats.Score.Value local str1 = "Your income: " game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextButton.Text = str1..str wait(1) end end script.Parent.MouseButton1Click:connect(onClick)
Oh, then you need an event. I prefer anonymous functions when I do events, but you can do it with a normal function just as easily. I will do a normal function here, since that's what you asked.
function onClick() while true do stats.Score.Value = stats.Score.Value + 1 local str = stats.Score.Value local str1 = "Your income: " player.PlayerGui.ScreenGui.Frame.TextButton.Text = str1..str wait(1) end end script.Parent.MouseButton1Down:connect(onClick)