Random.new keeps getting the same thing

What I want to achieve is it will pick a new random value from the table once player chatted ‘/changeword’ but keeps getting the starting word

local words = {'no','ok','help','yes','daddy','come','here'}

game.Players.PlayerAdded:Connect(function(p)
	local nallowedword = Instance.new('StringValue')
	nallowedword.Name = 'Word'
	nallowedword.Parent = p

	local choosedword = words[Random.new(tick()):NextInteger(1,#words)]
	
	nallowedword.Value = choosedword
	
	print('Starting word: '..choosedword)
	
	p.Chatted:Connect(function(chat)
		if chat == '/changeword' then
			nallowedword.Value = choosedword
			print('Word changed to: '..choosedword)
		end
		
		if string.find(chat,nallowedword.Value) then
			p:Kick('You said the word: '..nallowedword.Value)
		end
	end)
end)

you can add another variable after the /changeword to choose another random word
like so

p.Chatted:Connect(function(chat)
		if chat == '/changeword' then
             local chosenword2
              repeat wait() chosedword2 = 
              words[Random.new(tick()):NextInteger(1,#words)] until chosedword ~= 
              chosedword2 -- to not get the same word
		       nallowedword.Value = chosedword2
			print('Word changed to: '..choosedword2)
		end
		
		if string.find(chat,choosedword) then
			p:Kick('You said the word: '..choosedword)
		end
	end)
end)

Thanks, didn’t think of that heh…

1 Like

Your variable are funny bro LOL…

1 Like