Script getting no errors whatsoever, And I’ve said each number, from 1-10
The code in question:
--Locals--
--Local
local Number = math.random(1,10)
game.Players.PlayerAdded:Connect(function(Plr)
Plr.Chatted:Connect(function(Msg)
if Msg == Number then --he
print("You got the number right")
end
--if Msg ==
end)
end)
--
I’ve looked in the console after I’ve said the said numbers, but nothing happens is there an problem here or something, or is the script working?
The error is that you’re comparing a string with a number, as an example 2 =/= "2" you can solve this by using tonumber().
Also you should do this with a LocalScript and update the Number variable each time the players chats:
local Seed = Random.new()
local Players = game:GetService("Players")
local Client = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
Client.Chatted:Connect(function(msg)
local RandomNumber = Seed:NextInteger(1, 10)
if tonumber(msg) == RandomNumber then
print("You got the number")
end
end)