I want to make a script where whenever the person says a number something happens but when I started a problem started occurring please help It prints nill when i say it. I think it is something to do with my answer my script is :
game.Players.PlayerAdded:Connect(function(player) math.randomseed(tick()) for _ = 1, 1 do local answer = (math.random(100)) end player.Chatted:Connect(function(message) if message == "red" then print(awnswer) end end) end)
Youre doing local wrong. Get rid of your for loop. Instead do:
game.Players.PlayerAdded:Connect(function(player) math.randomseed(tick()) local answer = math.random(100) player.Chatted:Connect(function(message)player.Chatted:Connect(function(message) if message == "red" then print(answer) end end) end)
hope this helps
btw output should just be a random number