I’m making this thing where I’m supposed to click whether it’s naughty or nice in this christmas game. But it’s supposed to only add 1 but it adds more than 1 every round. I thought it was because it was playing the function multiple times and I added returns but it still doesn’t work. Here is my code:
local non = script.Parent.ScreenGui.Non
local prompt
local nice
local player = game.Players.LocalPlayer
click.MouseClick:Connect(function()
Play()
end)
function Play()
script.Parent.ScreenGui.Non.Visible = true
prompt = math.random(1, 6)
if prompt == 1 then
non.Promptnon.Text = "He kicked somebody's dog"
nice = false
end
if prompt == 2 then
non.Promptnon.Text = "He bullies"
nice = false
end
if prompt == 3 then
non.Promptnon.Text = "He punched his brother"
nice = false
end
if prompt == 4 then
non.Promptnon.Text = "He likes dogs"
nice = true
end
if prompt == 5 then
non.Promptnon.Text = "He doesn't bother anybody"
nice = true
end
if prompt == 6 then
non.Promptnon.Text = "He helps people"
nice = true
end
non.Nice.MouseButton1Click:Connect(function()
if nice == true then
player.Leaderstats.Coins.Value += 1
Play()
return
else
Play()
return
end
end)
non.Naughty.MouseButton1Click:Connect(function()
if nice == false then
player.Leaderstats.Coins.Value += 1
Play()
return
else
Play()
return
end
end)
end```